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
Yu
Yu
Level II

How to use the “if” function to do the loop in graph builder?

I want to use the “if” function to do the loop in graph builder.

Here is the data table. I try to describe it as clearly as possible.

 

The Column 3 in the data table  has 8 types characters, They can be divided into two groups by “T” and “unT”.

And  each group has 4 different characters. That mean the mark_length is 4.

In the graph builder, I try to use Solid line for the “T” group, and use Dotted line for “unT” group.

I also try to use same color for the “T+290767” and “unT+290767”.

But if each group has 2 or 3 or 5 different characters, how could I use the “if ” function to  solve the problem?

Best Reguard.

Close All (Data Tables, No Save);

names default to here(1);

CreateDirectory("C:\Desktop");
Set Path Variable("root1", "C:\Desktop");
Get Path Variable("root1");

dt1 = Open("$root1\data table 3.csv");

aa = Graph Builder(
	Size( 850, 600 ),
	Show Control Panel( 0 ),
	Categorical Color Theme( "strong " ),
	Show Legend( 0 ),
	Variables( X( :Column 4 ), 
	           Y( :Column 2 ), 
	           Overlay( : Column 3 ) ),
	Elements(
		Points( X, Y, Legend( 5 ) ),
		Line Of Fit( X, Y, Legend( 8 ), Degree( "Quadratic" ), Confidence of Fit( 0 ) )
	),
	SendToReport( 
	    Dispatch(
			{},
			"aa",
			ScaleBox,
			{Min( 53 ), Max( 76 ), Inc( 2 ), Minor Ticks( 1 ), 
			Label Row({Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 27 )})}
		),
		Dispatch(
			{},
			"bb",
			ScaleBox,
			{Label Row({Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 27 )})}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
		Dispatch( {}, "X title", TextEditBox, {Set Font Size( 27 )} ),
		Dispatch( {}, "Y title", TextEditBox, {Set Font Size( 27 )} ),
		Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 )} ),
		Dispatch( {}, "Graph Builder", FrameBox, {Line Width Scale( 2 )} ),
		If(( :mark_length[1]) == 4,
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					5,
					Base( 0, 0, 0 ),
					Base( 1, 0, 0 ),
					Base( 2, 0, 0 ),
					Base( 3, 0, 0 ),
					Base( 4, 0, 4 ),
					Base( 5, 0, 5 ),
					Base( 6, 0, 6 ),
					Base( 7, 0, 7 ),
					Properties( 4, {Line Color( -14948892 ), Marker( "Circle" )} ),
					Properties( 5, {Line Color( -3636920 ), Marker( "Circle" )} ),
					Properties( 6, {Line Color( -5091146 ), Marker( "Circle" )} ),
					Properties( 7, {Line Color( -9981603 ), Marker( "Circle" )} )
				), Legend Model(
					8,
					Properties( 4, {Line Color( -14948892 ), Line Style( "Dotted" )} ),
					Properties( 5, {Line Color( -3636920 ), Line Style( "Dotted" )} ),
					Properties( 6, {Line Color( -5091146 ), Line Style( "Dotted" )} ),
					Properties( 7, {Line Color( -9981603 ), Line Style( "Dotted" )} )
				)}
			),
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					5,
					Base( 0, 0, 0 ),
					Base( 1, 0, 0 ),
					Base( 2, 0, 2 ),
					Base( 3, 0, 3 ),
					Properties( 2, {Line Color( -14948892 ), Marker( "Circle" )} ),
					Properties( 3, {Line Color( -3636920 ), Marker( "Circle" )} )
				),Legend Model(
					8,
					Properties( 2, {Line Color( -14948892 ), Line Style( "Dotted" )} ),
					Properties( 3, {Line Color( -3636920 ), Line Style( "Dotted" )} ),
				//Properties( 4, {Line Color( -5091146 ), Line Style( "Dotted" )} )
				)}
			)
		)		
	)
);

 

1 REPLY 1
Highlighted
txnelson
Super User

Re: How to use the “if” function to do the loop in graph builder?

I think this may give you what you want, without having to specify each different graphic output.  I simply created a new column called "Grouping" that are the remaining characters from Column 3, if you strip off the "T" and "UnT".  I then use the Grouping column as a Page operation in the Graph Builder

page.PNG

Close All (Data Tables, No Save);

names default to here(1);

CreateDirectory("C:\Desktop");
Set Path Variable("root1", "C:\Desktop");
Get Path Variable("root1");

dt1 = Open("$root1\data table 3.csv");

dt1 << new column("Grouping",character,formula(word(2,:Column 3, "+")));

aa = Graph Builder(
	Size( 850, 600 ),
	Show Control Panel( 0 ),
	Categorical Color Theme( "strong " ),
	Show Legend( 0 ),
	Variables( X( :Column 4 ), 
	           Y( :Column 2 ),
	           Page( :Grouping ), 
	           Overlay( : Column 3 ) ),
	Elements(
		Points( X, Y, Legend( 5 ) ),
		Line Of Fit( X, Y, Legend( 8 ), Degree( "Quadratic" ), Confidence of Fit( 0 ) )
	),
	SendToReport( 
	    Dispatch(
			{},
			"MCW_nm 10N ID",
			ScaleBox,
			{Min( 53 ), Max( 76 ), Inc( 2 ), Minor Ticks( 1 ), 
			Label Row({Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 27 )})}
		),
		Dispatch(
			{},
			"eqSWNRntr_dB R1 ID",
			ScaleBox,
			{Label Row({Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 27 )})}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
		Dispatch( {}, "X title", TextEditBox, {Set Font Size( 27 )} ),
		Dispatch( {}, "Y title", TextEditBox, {Set Font Size( 27 )} ),
		Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 )} ),
		Dispatch( {}, "Graph Builder", FrameBox, {Line Width Scale( 2 )} ),
		If(( :mark_length[1]) == 4,
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					5,
					Base( 0, 0, 0 ),
					Base( 1, 0, 0 ),
					Base( 2, 0, 0 ),
					Base( 3, 0, 0 ),
					Base( 4, 0, 4 ),
					Base( 5, 0, 5 ),
					Base( 6, 0, 6 ),
					Base( 7, 0, 7 ),
					Properties( 4, {Line Color( -14948892 ), Marker( "Circle" )} ),
					Properties( 5, {Line Color( -3636920 ), Marker( "Circle" )} ),
					Properties( 6, {Line Color( -5091146 ), Marker( "Circle" )} ),
					Properties( 7, {Line Color( -9981603 ), Marker( "Circle" )} )
				), Legend Model(
					8,
					Properties( 4, {Line Color( -14948892 ), Line Style( "Dotted" )} ),
					Properties( 5, {Line Color( -3636920 ), Line Style( "Dotted" )} ),
					Properties( 6, {Line Color( -5091146 ), Line Style( "Dotted" )} ),
					Properties( 7, {Line Color( -9981603 ), Line Style( "Dotted" )} )
				)}
			),
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					5,
					Base( 0, 0, 0 ),
					Base( 1, 0, 0 ),
					Base( 2, 0, 2 ),
					Base( 3, 0, 3 ),
					Properties( 2, {Line Color( -14948892 ), Marker( "Circle" )} ),
					Properties( 3, {Line Color( -3636920 ), Marker( "Circle" )} )
				),Legend Model(
					8,
					Properties( 2, {Line Color( -14948892 ), Line Style( "Dotted" )} ),
					Properties( 3, {Line Color( -3636920 ), Line Style( "Dotted" )} ),
				//Properties( 4, {Line Color( -5091146 ), Line Style( "Dotted" )} )
				)}
			)
		)		
	)
);
Jim
Article Labels

    There are no labels assigned to this post.