cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lala
Level VII

How do add different background colors to this drawing in JMP?

Use the data from Big Class.jmp to draw pictures according to the following JSL,
The X-axis is grouped by age and compared according to the number of occurrences of each age and the average of the total number of ages
If the number of occurrences of this age is greater than the average, the background color of this age column is red;Otherwise it is green.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
d2 = dt << Summary( Group( age ), Freq( "0" ), Weight( "0" ), Link to original data table( 0 ) );
Column( d2, 2 ) << set name( "co" );
s = Median( d2[0, 2] );
ca = "than";
New Column( ca );
Column( ca ) << Formula( co > s );
d2 << run formulas;
Column( ca ) << deleteFormula;
dt << Update( With( d2 ), Match Columns( age = age ), Add Columns from Update table( than ) );
p1 = dt << Graph Builder(
	Variables( X( :weight ), Y( :height ), Group X( :age ), Color( :sex ) ),
	Elements( Bar( X, Y, Legend( 5 ), Response Axis( "X" ) ) )
);

2024-01-27_20-37-29.png

1 ACCEPTED SOLUTION

Accepted Solutions
lala
Level VII

回复: How do add different background colors to this drawing in JMP?

9 REPLIES 9
lala
Level VII

回复: How do add different background colors to this drawing in JMP?

This effect、Thanks!

2024-01-27_20-37-29.png

lala
Level VII

回复: How do add different background colors to this drawing in JMP?

In addition, how to mark ① a place on the graph, how to write JSL so that the "Hover label" function of clicking there can obtain the name, height and other data of this graph position to write different variables

 

2024-01-27_21-00-52.png

jthi
Super User

回复: How do add different background colors to this drawing in JMP?

One option is to create one additional column to your table which indicates the maximum value possible and then create a line chart using that with fill below enabled.

 

Column 7 has just value 70 in all rows

jthi_0-1706361888217.png

Graph Builder(
	Size(570, 798),
	Variables(
		X(:weight),
		Y(:height),
		Y(:Column 7, Position(1)),
		Group X(:age),
		Overlay(:than),
		Color(:sex)
	),
	Elements(
		Bar(X, Y(1), Legend(5), Response Axis("X")),
		Line(Y(2), Color(0), Legend(8), Fill("Fill Below"))
	),
	SendToReport(
		Dispatch({"Bar"}, "", OutlineBox, {Close(0)}),
		Dispatch({"Line"}, "", OutlineBox, {Close(0)}),
		Dispatch(
			{},
			"height",
			ScaleBox,
			{Min(0), Max(70.3382899628253), Inc(10), Minor Ticks(0)}
		),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(0, {Line Color(35)}, Item ID("0", 1)),
				Properties(-1, {Line Color(35)}, Item ID("Mean(Column 7)", 1))
			)}
		)
	)
)
-Jarmo
lala
Level VII

回复: How do add different background colors to this drawing in JMP?

Thanks Experts!

2024-01-27_21-51-37.png

lala
Level VII

回复: How do add different background colors to this drawing in JMP?

  • What are the specific steps of manual operation of this JSL?

 

Thank jthi !

jthi
Super User

回复: How do add different background colors to this drawing in JMP?

Create column with all values of 70, create graph builder with bar chart and line chart (x: weight, yaxis: height + column 7, overlay: than, color: sex) and modify line chart settings (fill to fill below), disable x axis from line chart, modify legend as needed. You should be able to track most of the changes just be checking out the graph builder and what has been set and where

jthi_0-1710954185426.png

 

-Jarmo
lala
Level VII

回复: How do add different background colors to this drawing in JMP?

  • How can I make both a bar chart and a line chart on the Y-axis?

Thanks!

2024-03-21_07-21-38.png

txnelson
Super User

回复: How do add different background colors to this drawing in JMP?

Right click on the graph, and select Add=>Line

Jim
lala
Level VII

回复: How do add different background colors to this drawing in JMP?

Thanks Experts!

2024-03-21_07-43-27.png