cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
Plotasaurus
Level II

Force JMP to match line of fit line color to marker color along with a forced line style

JMP 17.2.0

 

EDIT: Example data file uploaded with main post.

 

I have run into a slight issue when trying to customize my graphs, either through graph builder or via JSL (or combo). I have scoured the JMP forums and found some similar topics, but no solution that actually works for what I specifically want to do.

 

What I want JMP to do is: color code my markers by test number (or in the code its RUN_NUM), choose different marker shapes by test number, and then plot a quadratic line of fit for each test number where the color of the line matches the color of the markers for each test number and the line of fit is also always a dashed line for every test number. The other thing to note here is that I don't want to permanently assign colors to specific tests using a feature like row color states. I want the graph to use the same color scheme no matter which test numbers I plot as this data is part of a growing data table that may end up with 100-200 tests. For example, if I plot Tests 1-5, I want them to always plot as a color scheme like blue, red, green, orange, purple so that if I change what I plot, say now Tests 1-4 + Test 7 the color scheme is the same for the five tests plotted.

 

I can almost get all the above features, but I fall short in getting the color coding of the markers and line of fit to match. Here's my process so far in graph builder/JSL:

  1. I plot my data points in GB, usually four data points per test.
  2. I drag 'test number' to the 'overlay' space in GB This color codes my data points per test.
  3. I drag 'test number' to the 'color' space in GB. This chooses a shape for each test.
  4. I click the line of fit option which adds the line to the graph, but they have different line styles and the color is always the JMP Default Blue.

 

So using the above steps, I'm close but not quite there. Using the JMP forums, I've found a good way to add JSL to modify the line style and/or color, but not both together. I can save my GB graph and then edit the JSL a bit to get one or the other.

 

Note: In the code below Test Number = RUN_NUM

 

By adding this at the top of my graph code:

dts = dt << Summary(
			Group( :RUN_NUM ),
			Freq( "None" ),
			Weight( "None" ),
			invisible
		);

dlist = Column (dts, "RUN_NUM") << get values;
Close (dts, NoSave);
show (dlist);

And adding this at the bottom of my graph code:

For (i = 0, i < N Items (dlist), i++, 
	gb << SendToReport( 
			Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				1, //change this legend number to match what is above in graph builder...when modifying this code
					Properties (i, {Marker Size(8)} )
				);
			})));

For (i = 0, i < N Items (dlist), i++, 
	gb << SendToReport( 
			Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				2, //change this legend number to match what is above in graph builder...when modifying this code
					Properties (i, {Line Style( 2 ), Line Width (1)} )
				);
			})));

I am able to use the above code to modify the line of fit properties. However, I've found some quirks.

  1. As is, the above code modifies the line style to dashed for every line of fit
  2. As is, the above code modifies the line width for every line of fit
  3. As is, all lines of fit are colored black for some reason

 

It's almost everything I want except the lines are black. Next quirk:

  1. If I remove "test number" from the "color" property in GB all my lines of fit now match the color of the marker and they dynamically change with each selected test! They are also all dashed and correct width.
  2. Now my markers are all circles instead of unique shapes that change when selecting different tests and they ignore my specified marker size in the code.

 

So now I've gotten it all except the marker shape. This is where I'm stuck. It seems I must live with one of two outcomes:

  1. Everything I want except line of fits are always black lines
  2. Everything I want except marker shapes are always circles (and small)

Picture1.png

 

Does anyone know of a way to accomplish everything I want for a custom graph? Maybe there is something I am misunderstanding? Any help is greatly appreciated.

 

Some previous relevant JMP discussions:

  1. https://community.jmp.com/t5/Discussions/Match-Line-Color-of-Normal-Quantile-Plot-to-Row-Color-Set-i...
  2. https://community.jmp.com/t5/Discussions/Change-color-theme-in-plot-legend-of-FIt-Curve/td-p/368792
  3. https://community.jmp.com/t5/Discussions/assign-marker-style-line-style-by-quot-string-quot-or-speci...

 

Full GB code:

dt = Data Table( "DT" );


//this short section makes a list of all runs/tests in the data table
//then all the runs are counted in a later section for a "for loop"
dts = dt << Summary(
			Group( :RUN_NUM ),
			Freq( "None" ),
			Weight( "None" ),
			invisible
		);

dlist = Column (dts, "RUN_NUM") << get values;
Close (dts, NoSave);
show (dlist);

//below is the graph builder code
gb = Graph Builder(
	Size( 850, 600 ),
	Show Legend( 1 ),
	Show Title( 0 ),
	Show Footer( 0 ),
	Fit to Window( "Off" ),
	Variables(
		X( :TEMP ),
		Y( :CONVERSION ),
		Overlay( :RUN_NUM ),
		Color( :RUN_NUM )
	),
	Elements(
		Points( X, Y, Legend( 1 ) ),
		Line Of Fit(
			X,
			Y,
			Legend( 2 ),
			Degree( "Quadratic" ),
			Confidence of Fit( 0 )
		)
	),
	SendToReport(
		Dispatch( {"Line Of Fit"}, "", OutlineBox, {Close( 0 )} ),
		Dispatch(
			{},
			"TEMP",
			ScaleBox,
			{Min( 50 ), Max( 100 ), Inc( 5 ), Minor Ticks( 4 ),
			Label Row(
				{Show Major Grid( 1 ), Set Font Size( 18 ), Set Font Style( "Bold" )
				}
			)}
		),
		Dispatch(
			{},
			"CONVERSION",
			ScaleBox,
			{Min( 40 ), Max( 60 ), Inc( 5 ), Minor Ticks( 4 ),
			Label Row(
				{Automatic Font Size( 0 ), Show Major Grid( 1 ),
				Show Minor Grid( 1 ), Set Font Size( 18 ), Set Font Style( "Bold" )}
			)}
		),
		Dispatch(
			{},
			"X title",
			TextEditBox,
			{Set Text( "Temperature" ), Set Font Size( 20 ),
			Set Font Style( "Bold" )}
		),
		Dispatch(
			{},
			"Y title",
			TextEditBox,
			{Set Text( "Conversion" ), Set Font Size( 20 ),
			Set Font Style( "Bold" )}
		),
	)
);


//this loop goes through all runs and changes lines to dashed and changes their width

For (i = 0, i < N Items (dlist), i++, 
	gb << SendToReport( 
			Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				1, //change this legend number to match what is above in graph builder...when modifying this code
					Properties (i, {Marker Size(8)} )
				);
			}
		)
	)
);

For (i = 0, i < N Items (dlist), i++, 
	gb << SendToReport( 
			Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				2, //change this legend number to match what is above in graph builder...when modifying this code
					Properties (i, {Line Style( 2 ), Line Width (1)} )
				);
			}
		)
	)
);

 

10 REPLIES 10
Plotasaurus
Level II

Re: Force JMP to match line of fit line color to marker color along with a forced line style

Thanks for the two replies. I'll take some time and play around to see how these work for me.

Recommended Articles