cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
BabyDoragon
Level II

How to detect changes in the order of the X-axis?

How can I detect changes in the order of the X-axis? I am using the following JSL to mark the background color, but users can change the order of the X-axis as shown in the image below. If I cannot detect that the user has made this change to the graph, the previously marked background color area will not follow the new order and will not be updated.
For example, if I originally marked age 13 and the user changes the order to 'Ascending, Weight', I need to know that the user has triggered the order change so that the red marking can be correctly updated to the position of age 13, instead of staying fixed.

What methods can I use to detect when the user changes the X-axis order, or how can I make the background color marking automatically change with the order?

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
GraphX =dt<< Graph Builder(
	Size( 534, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( :weight ), Overlay( :sex ) ),
	Elements( Box Plot( X, Y, Legend( 4 ) ) )
);
rep1 = GraphX << report;
frameboxDCRFH = rep1 << XPath( "//FrameBox" );
frameboxDCRFH << Add Graphics Script(
	Transparency( 0.1 );
	Fill Color( "Red" );
	
	Rect( 0.5, Y Origin() + Y Range(), 1.5, Y Origin(), 1 )
	
	;
);

BabyDoragon_0-1752053161562.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to detect changes in the order of the X-axis?

And you can improve the plot by moving the "extra" column to right side

jthi_0-1752059912299.png

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << New Column("Column 6", Numeric, "Continuous", 
	Set Property(
		"Axis",
		{Show Major Ticks(0), Show Minor Ticks(0), Show Labels(0), Min(0.49),
		Max(0.5), Inc(0.2), Minor Ticks(0), Label Row(
			{Show Major Labels(0), Show Major Ticks(0), Show Minor Ticks(0)}
		)}
	),
	Formula(
		If(:age == 13,
			1
		,
			.
		)
	);
);
gb = dt << Graph Builder(
	Size(712, 621),
	Show Control Panel(0),
	Variables(X(:age), Y(:weight), Y(:Column 6, Position(1), Side("Right")), Overlay(:sex)),
	Elements(Bar(X, Y(2), Overlay(0), Legend(9), Summary Statistic("Median")), Box Plot(X, Y(1), Legend(4))),
	SendToReport(
		Dispatch({}, "400", ScaleBox, {Legend Model(9, Properties(0, {Fill Color(67), Transparency(0.2)}, Item ID("Median(Column 6)", 1)))}),
		Dispatch({}, "Y r title", TextEditBox, {Set Text("")}),
		Dispatch({}, "400", LegendBox, {Legend Position({9, [2], 4, [0, 1, -3, -3]})})
	)
);

 

-Jarmo

View solution in original post

9 REPLIES 9
jthi
Super User

Re: How to detect changes in the order of the X-axis?

I don't think we have access to such handlers so you would have to either take it into account in your graphic script or create the coloring using separate plot. One way of taking it into account with graphic script

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(534, 492),
	Show Control Panel(0),
	Variables(X(:age), Y(:weight), Y(:Column 6, Position(1)), Overlay(:sex)),
	Elements(
		Box Plot(X, Y(1), Legend(4)),
		Points(X, Y(2), Overlay(0), Legend(6), Summary Statistic("Median"))
	)
);

fb = Report(gb)[FrameBox(1)];
fb << Add Graphics Script(
	fb = Report(gb)[FrameBox(1)];
	barseg = fb << Find Seg(MarkerSeg(1));
	xval = (barseg << Get X Values)[1];
	Transparency(0.1);
	Fill Color("Red");
	Rect(xval - 0.5, Y Origin() + Y Range(), xval + 0.5, Y Origin(), 1)
);

Formula for Column 6

If(:age == 13,
	Col Median(:weight, :age),
	.
)

Adding bar chart for the color

jthi_0-1752056529103.png

jthi_1-1752056537005.png

 

 

-Jarmo
jthi
Super User

Re: How to detect changes in the order of the X-axis?

And you can improve the plot by moving the "extra" column to right side

jthi_0-1752059912299.png

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << New Column("Column 6", Numeric, "Continuous", 
	Set Property(
		"Axis",
		{Show Major Ticks(0), Show Minor Ticks(0), Show Labels(0), Min(0.49),
		Max(0.5), Inc(0.2), Minor Ticks(0), Label Row(
			{Show Major Labels(0), Show Major Ticks(0), Show Minor Ticks(0)}
		)}
	),
	Formula(
		If(:age == 13,
			1
		,
			.
		)
	);
);
gb = dt << Graph Builder(
	Size(712, 621),
	Show Control Panel(0),
	Variables(X(:age), Y(:weight), Y(:Column 6, Position(1), Side("Right")), Overlay(:sex)),
	Elements(Bar(X, Y(2), Overlay(0), Legend(9), Summary Statistic("Median")), Box Plot(X, Y(1), Legend(4))),
	SendToReport(
		Dispatch({}, "400", ScaleBox, {Legend Model(9, Properties(0, {Fill Color(67), Transparency(0.2)}, Item ID("Median(Column 6)", 1)))}),
		Dispatch({}, "Y r title", TextEditBox, {Set Text("")}),
		Dispatch({}, "400", LegendBox, {Legend Position({9, [2], 4, [0, 1, -3, -3]})})
	)
);

 

-Jarmo
BabyDoragon
Level II

Re: How to detect changes in the order of the X-axis?

I hope to remove the axis on the right side. However, I only know how to manually modify the "show Properties" like in the figure below and set the Visibility to Hidden. How can I achieve this setting using JSL?

 

BabyDoragon_0-1752130288104.png

 

BabyDoragon
Level II

Re: How to detect changes in the order of the X-axis?

I would also like to automatically remove the Median marker in the Legend Setting using JSL. The image below shows how to remove it manually. How can I hide it using JSL?

BabyDoragon_1-1752131548341.png

 

jthi
Super User

Re: How to detect changes in the order of the X-axis?

What are your axis settings? You can hide/remove most of the axis by using those. Median shouldn't add marker unless you are using points with the bar chart. If you mean the legend item and not marker, easiest is to hide it manually and copy the script.

-Jarmo
BabyDoragon
Level II

Re: How to detect changes in the order of the X-axis?

I have a derivative question.
If the original graph already has a variable labeled 'Color' and the bar chart color cannot be controlled to be red, what should I do to fix it in order to maintain the red color?
The following JSL should address these two points:
1. Add color() to the variablesVariables(X(:age), Y(:weight), Y(:Column 6, Position(1), Side("Right")), Overlay(:sex),Color("sex")),
2. Change Fill color() to red: Dispatch({}, "400", ScaleBox, {Legend Model(9, Properties(0, {Fill Color("Red"), Transparency(0.2)}, Item ID("Median(Column 6)", 1)))}),
BabyDoragon_0-1752142615780.png

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << New Column("Column 6", Numeric, "Continuous", 
	Set Property(
		"Axis",
		{Show Major Ticks(0), Show Minor Ticks(0), Show Labels(0), Min(0.49),
		Max(0.5), Inc(0.2), Minor Ticks(0), Label Row(
			{Show Major Labels(0), Show Major Ticks(0), Show Minor Ticks(0)}
		)}
	),
	Formula(
		If(:age == 13,
			1
		,
			.
		)
	);
);
gb = dt << Graph Builder(
	Size(712, 621),
	Show Control Panel(0),
	Variables(X(:age), Y(:weight), Y(:Column 6, Position(1), Side("Right")), Overlay(:sex),Color("sex")),
	Elements(Bar(X, Y(2), Overlay(0), Legend(9), Summary Statistic("Median")), Box Plot(X, Y(1), Legend(4))),
	SendToReport(
		Dispatch({}, "400", ScaleBox, {Legend Model(9, Properties(0, {Fill Color("Red"), Transparency(0.2)}, Item ID("Median(Column 6)", 1)))}),
		Dispatch({}, "Y r title", TextEditBox, {Set Text("")}),
		Dispatch({}, "400", LegendBox, {Legend Position({9, [2], 4, [0, 1, -3, -3]})})
	)
);
jthi
Super User

Re: How to detect changes in the order of the X-axis?

Disable Color from bar charts variables and change the color?

-Jarmo
BabyDoragon
Level II

Re: How to detect changes in the order of the X-axis?

I set the color of the bar in Customize Graph, but no changes have occurred. 

Or should I set the color of the bar in another panel? I couldn't find any other place to set the bar color.

BabyDoragon_0-1752142886693.png

 

jthi
Super User

Re: How to detect changes in the order of the X-axis?

After I run your script, I disable Color for Bar (Right)

jthi_0-1752143438463.png

Then I can modify Median (Column 6)

jthi_1-1752143473763.png

 

-Jarmo

Recommended Articles