Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
ivomdb
Level III

How to save each graph from single window in graph builder into a different file format than jmp?

Hi All,

 

I have saved the script from graph builder to produce a desired graph. I have dragged my variables and dragged my list (:Sample) onto the Wrap to produce the same graph for each category. I am trying to figure out a way of printing the same graph type for all. The issue is that running the script from graph builder will only produce one graph (which ever comes first). I thought that I would need a Loop and I have written below but does not work. Is there anyone that could give me some clues on how to do this or if you could tell me what am I doing wrong?

 

for(g=1, g<=N items(::Sample), g++,
	For(i=1,i<=N items(Eval(::Sample[g])), i++,

gb= dt4 << Graph Builder(
	Size( 894, 625 ),
	Legend Position( "Bottom" ),
	Show Title( 0 ),
	Variables(
		X( :Days ),
		Y( :Model Biogas yield ),
		Y( :Biogas Yield, Position( 1 ) ),
		Group X( :Sample, Show Title( 0 ), N View Levels( 1 ) )
	),
	Elements(
		Points( X, Y( 2 ), Legend( 14 ), Jitter Limit( 1.1193 ) ),
		Smoother( X, Y( 1 ), Legend( 15 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Days",
			ScaleBox,
			{Min( 0 ), Max( 21 ), Inc( 1 ), Minor Ticks( 1 ),
			Label Row(
				{Inside Ticks( 1 ), Set Font( "Calibri" ), Set Font Size( 14 )}
			)}
		),
		Dispatch(
			{},
			"Model Biogas yield",
			ScaleBox,
			{Min( 0 ), Max( 700 ), Inc( 50 ), Minor Ticks( 0 ),
			Label Row(
				{Inside Ticks( 1 ), Set Font( "Calibri" ), Set Font Size( 14 )}
			)}
		),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				14,
				Level Name( 0, "Experimental", Item ID( "Biogas Yield", 1 ) ),
				Properties( 0, {Marker Size( 5 )}, Item ID( "Biogas Yield", 1 ) )
			), Legend Model(
				15,
				Level Name( 0, "Model", Item ID( "Smooth(Model Biogas yield)", 1 ) ),
				Properties(
					0,
					{Line Color( 32 ), Line Width( 3 )},
					Item ID( "Smooth(Model Biogas yield)", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"X title",
			TextEditBox,
			{Set Font( "Calibri" ), Set Font Size( 14 )}
		),
		Dispatch(
			{},
			"Y title",
			TextEditBox,
			{Set Font( "Calibri" ), Set Font Size( 14 ),
			Set Text( "Biogas yield (m3/t VS)" )}
		)
	)
);

gb<< Save picture ("C:\data\Graph Builder_" || ::Sample[g]||".jpg", JPEG);
););

 

16 REPLIES 16
Highlighted
txnelson
Super User

Re: How to save each graph from single window in graph builder into a different file format than jmp

Can you supply what the value of ::Sample is? You seem to be writing on top of the same file multiple times......
Jim
Highlighted
ivomdb
Level III

Re: How to save each graph from single window in graph builder into a different file format than jmp

It is not a value but rather names of 12 categories. Each will have graph.
Highlighted
txnelson
Super User

Re: How to save each graph from single window in graph builder into a different file format than jmp

The Graph Builder code that you have specified, only produces one graph. And when you loop through g and I, you are not changing anything in the Graph Builder specification, that would indicate that you want anything different in the graph that is produced. What are you expecting to change from graph to graph?
Jim
Highlighted
ivomdb
Level III

Re: How to save each graph from single window in graph builder into a different file format than jmp

I would like to keep the same graph. I just want to save the graph 12 times or save it by :Sample regardless and save it in a file that has the correspondent name in :Sample . Does that make sense?
Highlighted
txnelson
Super User

Re: How to save each graph from single window in graph builder into a different file format than jmp

OK, but I will once again ask for you to show what the variable ::Sample is. Is it a JSL list, or a character variable???? What is it's value?
Jim
Highlighted
ivomdb
Level III

Re: How to save each graph from single window in graph builder into a different file format than jmp

Yes It is a JSL List
Highlighted
txnelson
Super User

Re: How to save each graph from single window in graph builder into a different file format than jmp

OK.....I will try to be more specific......I don't see how you are using a JSL list, and making it work....I would still like to see exactly what your variable ::sample value is.  Here is why:

If your ::sample is a character list

 

::sample = {"one", "Two", "three"};
For( g = 1, g <= N Items( ::Sample ), g++,
	For( i = 1, i <= N Items( Eval( ::Sample[g] ) ), i++, 

		Print( "C:\data\Graph Builder_" || ::Sample[g] || ".jpg" )
	)
);

the code fails with the following error:

 

 

::sample = {"one", "Two", "three"};
For( g = 1, g <= N Items( ::Sample ), g++,
	For( i = 1, i <= N Items( Eval( ::Sample[g] ) ), i++, 

		Print( "C:\data\Graph Builder_" || ::Sample[g] || ".jpg" )
	)
);

/*:

N Items() argument must be a list

If the list is a numeric list of values

 

 

::sample = {1, 2, 3};
For( g = 1, g <= N Items( ::Sample ), g++,
	Print( "C:\data\Graph Builder_" || ::Sample[g] || ".jpg" )
);

The code will fail when you attempt to concatenate the string in your save picture

 

 

argument should be character in access or evaluation of 'Concat' , Bad Argument( ::Sample[g] ), "C:\data\Graph Builder_" ||  /*###*/::Sample[g] ||  /*###*/".jpg" /*###*/

In the following script, error marked by /*###*/
::sample = {1, 2, 3};
For( g = 1, g <= N Items( ::Sample ), g++,
	Print(
		"C:\data\Graph Builder_" ||  /*###*/::Sample[g] ||  /*###*/".jpg" /*###*/
	)
);

So that is why I would like to see exactly what your ::sample list contains......

That would also help in interpreting what the purpose of your 2 loops are.

 

Jim
Highlighted
ivomdb
Level III

Re: How to save each graph from single window in graph builder into a different file format than jmp

I may be calling it the wrong thing. Still getting familiar with these terms. It is a nominal character. For each group of variables there is a Nominal character. Basically one column named Sample matching a group of variables. It is basically a fourth variable. So I guess I would need to also use a conditional sentence in this case?
Highlighted
ivomdb
Level III

Re: How to save each graph from single window in graph builder into a different file format than jmp

I have attached a screen shoot of the dt. 

 

example.png

Article Labels

    There are no labels assigned to this post.