cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

Annotations outside the graph area: location and annotations not copied with graph

DispersionSpark
Level I

Annotations outside the graph area

 

If you annotate (using Tools>Annotate) inside the graph area, that text is part of the graph when copied — it appears that an annotation outside the graph area is not copied with the graph.

 

What I would like is a single line of code that I could drop into every script that would note N in small text at the bottom right of each chart (below the X axis), and would be copied with the chart.

 

Pseudocode would be something like Text (<bottom right>, “n=” || char(<non-excluded rows>))

 

So multiple subquestions:

  1. Is there a trick to getting annotations (via Tools>Annotate) that copy with a graph?
  2. What JSL code do you use to position text at the bottom right of the background of a chart? (for example, is there a way of defining origin at the bottom right?)
  3. What JSL code do you use to get the number of non-excluded rows in a table? It seems this should be obvious, (something like Rows() - Excluded Rows()), but I don't see it...

JMP 17, macOS

1 ACCEPTED SOLUTION

Accepted Solutions


Re: Annotations outside the graph area: location and annotations not copied with graph

Yes, there's a way to put it below the chart area, assuming you have JMP 17, and assuming that you're working with the Graph Builder instead of the Fit Y by X Platform. The trick is to add a Caption Box, then set it to be an Axis Table, then overwrite the defaults by deleting all but one of the labels (also, I had to change the Tick Labels to "Short Divider" to make every label show up in a contingency table). This can be done via scripting as well; example below.

 

Jed_Campbell_0-1671633221294.png

Jed_Campbell_1-1671633489118.png

 

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

//Caption box as regular axis table 
graph_one = dt << Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :age ) ),
	Elements(
		Mosaic( X, Y, Legend( 6 ) ),
		Caption Box(
			X,
			Y,
			Legend( 7 ),
			Summary Statistic( "N" ),
			Location( "Axis Table" )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"sex",
			ScaleBox,
			{Label Row( 1, Tick Mark Style( "Short Mark" ) ),
			Label Row( 2, Tick Mark Style( "Short Divider" ) )}
		)
	)
);

//overwritten axis label with custom number (500)
graph_two = dt << Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :age ) ),
	Elements(
		Mosaic( X, Y, Legend( 6 ) ),
		Caption Box(
			X,
			Y,
			Legend( 7 ),
			Summary Statistic( "N" ),
			Location( "Axis Table" )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"sex",
			ScaleBox,
			{Label Row( 1, Tick Mark Style( "Short Mark" ) ),
			Label Row(
				2,
				{Tick Mark Style( "Short Divider" ),
				Tick Mark( Label( "18" ), Label( "" ) ),  //<----here
				Tick Mark( Label( "22" ), Label( "500" ) )} //<--here
			)}
		)
	)
);

 

View solution in original post

4 REPLIES 4
jthi
Super User


Re: Annotations outside the graph area: location and annotations not copied with graph

Not sure about question 1 but here is a script using << Add Graphic Script to add text to graph builders bottom right corner

Names Default To Here(1);

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

gb = dt << Graph Builder(
	Variables(X(:weight), Y(:height), Overlay(:sex)),
	Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11)))
);

Report(gb)[FrameBox(1)] << Add Graphics Script(
	included_rows = N Rows(dt) - N Items(dt << Get Excluded Rows());
	Text Color("Black");
	Text(Right Justified, 
		{X Origin() + X Range(), Y Origin()}, 
		Eval Insert("n=^included_rows^");
	);
);

jthi_0-1671562099616.png

 

You should be able to turn that script into a expression/function/add-in which you can then easily re-use.

 

-Jarmo


Re: Annotations outside the graph area: location and annotations not copied with graph

Thanks! That works well at putting the number in the chart itself (example below). Is there a way to put it below the chart area? 

It would seem that it is the bottom right of LineupBox (or AxisBox), but I can't get your approach to work with those. Suggestions?

 

Screenshot 2022-12-20 at 16.29.52.png

 


Re: Annotations outside the graph area: location and annotations not copied with graph

Yes, there's a way to put it below the chart area, assuming you have JMP 17, and assuming that you're working with the Graph Builder instead of the Fit Y by X Platform. The trick is to add a Caption Box, then set it to be an Axis Table, then overwrite the defaults by deleting all but one of the labels (also, I had to change the Tick Labels to "Short Divider" to make every label show up in a contingency table). This can be done via scripting as well; example below.

 

Jed_Campbell_0-1671633221294.png

Jed_Campbell_1-1671633489118.png

 

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

//Caption box as regular axis table 
graph_one = dt << Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :age ) ),
	Elements(
		Mosaic( X, Y, Legend( 6 ) ),
		Caption Box(
			X,
			Y,
			Legend( 7 ),
			Summary Statistic( "N" ),
			Location( "Axis Table" )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"sex",
			ScaleBox,
			{Label Row( 1, Tick Mark Style( "Short Mark" ) ),
			Label Row( 2, Tick Mark Style( "Short Divider" ) )}
		)
	)
);

//overwritten axis label with custom number (500)
graph_two = dt << Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :age ) ),
	Elements(
		Mosaic( X, Y, Legend( 6 ) ),
		Caption Box(
			X,
			Y,
			Legend( 7 ),
			Summary Statistic( "N" ),
			Location( "Axis Table" )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"sex",
			ScaleBox,
			{Label Row( 1, Tick Mark Style( "Short Mark" ) ),
			Label Row(
				2,
				{Tick Mark Style( "Short Divider" ),
				Tick Mark( Label( "18" ), Label( "" ) ),  //<----here
				Tick Mark( Label( "22" ), Label( "500" ) )} //<--here
			)}
		)
	)
);

 


Re: Annotations outside the graph area: location and annotations not copied with graph

Nice - thank you!