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
shampton82
Level VII

Need help with a script for broadcasting the Y axis lines on Graph Builder when using the "Page" layout function and keeping the Y axis Independant

Hey everyone,

While the new ability to stack the panels in Graph Builder is amazing a key to this amazingness is keeping the Y axis Independent of each other.  However, when you have a lot of panels(levels) and want to add in Y axis grid lines you have to do them one by one, which is horrible.  Any ideas on a  script that would allow you to index through each panel and add grid lines independently?

Here you can see I used the old school way of (in the big class dataset) copying the axis settings and broadcasting a paste of them and while it does add in the gridlines it sets all the Y axis ranges to the same as the copied panel settings.

shampton82_0-1740161785394.png

 

Thanks for any ideas!

 

Steve

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Need help with a script for broadcasting the Y axis lines on Graph Builder when using the "Page" layout function and keeping the Y axis Independant

Use XPath to get reference to the Axisboxes you are interested in (X, Y axis or both) and then do whatever you want with that list of axisboxes. This example enables Major Grid for Y-axis on all the frameboxes

Names Default To Here(1); 

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

gb = dt << Graph Builder(
	Size(893, 542),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Page(:age, Levels per Row(3)), Overlay(:sex)),
	Elements(Points(X, Y, Legend(9)))
);

abs = Report(gb) << XPath("//AxisBox");

yaxis = abs[2::NItems(abs)::2];

yaxis << Show Major Grid(1);

jthi_0-1740162499528.png

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Need help with a script for broadcasting the Y axis lines on Graph Builder when using the "Page" layout function and keeping the Y axis Independant

Use XPath to get reference to the Axisboxes you are interested in (X, Y axis or both) and then do whatever you want with that list of axisboxes. This example enables Major Grid for Y-axis on all the frameboxes

Names Default To Here(1); 

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

gb = dt << Graph Builder(
	Size(893, 542),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Page(:age, Levels per Row(3)), Overlay(:sex)),
	Elements(Points(X, Y, Legend(9)))
);

abs = Report(gb) << XPath("//AxisBox");

yaxis = abs[2::NItems(abs)::2];

yaxis << Show Major Grid(1);

jthi_0-1740162499528.png

 

-Jarmo

Re: Need help with a script for broadcasting the Y axis lines on Graph Builder when using the "Page" layout function and keeping the Y axis Independant

That was fast, Jarmo! I like your solution better, but here's another way using Eval(Parse()).

 

Names Default To Here( 1 );

//Manually add your reference line to the top left panel of the graph builder.
//Then run this script with the graph builder report in focus.

axisList = Current Report() << XPath( "//AxisBox" );

//Grab axis specifications from vertical axis of first panel
//(vertical axes are even-numbered items; horizontal axes are odd)
axspecList = axisList[2] << Get Script();
//find the Reference Line among the other specifications
For( i = 1, i <= N Items( axspecList ), i++,
	If( Left( Char( axspecList[i] ), 12 ) == "Add Ref Line",
		rlindex = i;
		Break();
	)
);

//Reference Line specification as string
rlstr = Char( axspecList[rlindex] );

//Apply Reference Line specification to the remaining panels
For( j = 4, j <= N Items( axisList ), j = j + 2,
	estr = "axisList[" || Char( j ) || "] <<" || rlstr;
	Eval( Parse( estr ) );
);

Recommended Articles