Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
nikles
Level V

Get number of frame boxes in a graphbuilder plot?

Hi.  I'd like to know if there is a good way to get the number of frame boxes in a graphbuilder plot.  I have a GB plot that contains 104 FB (8 X-groups, 13 Y-groups).  I've written a script to change the marker size for each FB.  

	Summarize(dtstack, frame_lis = By(:Freq, :Image, :Region));
	For(i=1, i<=NItems(frame_lis[1]), i++,
		Try(
			Report(gb) << Dispatch({}, "Graph Builder", FrameBox(i), 
				{Marker Size(1)}
			)
		)
	);

(credit to @ms in https://community.jmp.com/t5/Discussions/Can-t-change-all-marker-size-in-Graph-Builder-by-script/m-p... ).  But in my case, the Summarize statement overestimates the number of FB, as I've excluded several rows in my table containing certain values of Region, Image, or Freq.  This script works, but once the counter i exceeds the the actual number of FB in the GB plot, I begin getting error messages in the log ("Cannot find FrameBox[ "Graph Builder" ] at {}").  The "Try" statement was an attempt to prevent the error messages, but did not work.  At any rate, I'd prefer to avoid this by just computing the correct number of frame boxes to begin with.  Anyone have any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ih
ih
Level VII

Re: Get number of frame boxes in a graphbuilder plot?

To directly answer your question, you can count the items returned with an XPath query.  A better solution, though, is to just send the Marker Size message to all of the results returned with XPath rather than using Dispatch.

 

Names Default To Here( 1 );

dt = Open( "$sample_data\Big Class.jmp" );

gb = Graph Builder(
	Show Control Panel( 0 ), 
	Variables( X( :weight ), Y( :height ), Group Y( :sex ) ), 
	Elements( Points( X, Y, Legend( 1 ) ) ), 
);

//Count Frame boxes here
N Items( (gb << XPath( "//FrameBox" )) );

//Or just update them all
(gb << XPath( "//FrameBox" )) << Marker Size( 8 );

 

View solution in original post

2 REPLIES 2
Highlighted
ih
ih
Level VII

Re: Get number of frame boxes in a graphbuilder plot?

To directly answer your question, you can count the items returned with an XPath query.  A better solution, though, is to just send the Marker Size message to all of the results returned with XPath rather than using Dispatch.

 

Names Default To Here( 1 );

dt = Open( "$sample_data\Big Class.jmp" );

gb = Graph Builder(
	Show Control Panel( 0 ), 
	Variables( X( :weight ), Y( :height ), Group Y( :sex ) ), 
	Elements( Points( X, Y, Legend( 1 ) ) ), 
);

//Count Frame boxes here
N Items( (gb << XPath( "//FrameBox" )) );

//Or just update them all
(gb << XPath( "//FrameBox" )) << Marker Size( 8 );

 

View solution in original post

Highlighted
nikles
Level V

Re: Get number of frame boxes in a graphbuilder plot?

Thanks @ih . That seems to have worked well. For some reason I get an error when I try to accept your answer as the solution - but this was the solution.
Article Labels