- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Annotations outside the graph area: location and annotations not copied with graph
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:
- Is there a trick to getting annotations (via Tools>Annotate) that copy with a graph?
- 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?)
- 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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
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
)}
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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^");
);
);
You should be able to turn that script into a expression/function/add-in which you can then easily re-use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
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
)}
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Annotations outside the graph area: location and annotations not copied with graph
Nice - thank you!