Graph Builder y=x Line Not Tied to Specific GraphI am trying to work in Graph Builder to create a line with JSL of perfect correlation (y=x) for the scatterplot. See below using Restaurant Tips sample data as an example.

When I do this manually, here is the script that JMP generates:
Graph Builder(
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables( X( :Bill Amount ), Y( :Tip Amount ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Tip Amount", ScaleBox,
{Min( -0.062875 ), Max( 72.9215829464286 ), Inc( 10 ), Minor Ticks( 1 )}
),
Dispatch( {}, "Graph Builder", FrameBox,
{Add Graphics Script(
2,
Description( "" ),
Pen Color( "red" );
Y Function( x, x );
)}
)
)
); Note that this is tied to this specific graph.
How can a make this universal to apply to any graph builder chart I am working on? My ultimate goal is to make this an add-in or better yet a button on graph builder (if that is possible) to draw this line for any chart I am working on.
There is an old video and some old info in the Community on this, but all of it that I could find is tied to a specific chart. I think maybe I don't understand frame box very well. I tried some scripting variations using frame box but got nowhere.
Thanks as always for any help.
Automation and ScriptingmacOSRe: Graph Builder y=x Line Not Tied to Specific GraphMy specific application is that I often have to compare data from redundant sensors which ideally should be providing perfectly redundant data. Of course, reality intervenes and this is often not the case. So a scatterplot with the y=x line is my quick way to evaluate the data from the two sensors.
Re: Graph Builder y=x Line Not Tied to Specific Graphgreat idea - I use it sooo often!
-> I will add it to Graph Builder Toolbar : )
fbs = current report() << xpath("//FrameBox");
fbs << Add Graphics Script(
Pen Color( "gray" );
Y Function( x, x );
)
Re: Graph Builder y=x Line Not Tied to Specific GraphThis method should allow you to do what you want
names default to here(1);
dt =
// Open Data Table: Restaurant Tips.jmp
// → Data Table( "Restaurant Tips" )
Open( "$SAMPLE_DATA/Restaurant Tips.jmp" );
Graph Builder(
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables( X( :Bill Amount ), Y( :Tip Amount ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Tip Amount", ScaleBox,
{Min( -0.062875 ), Max( 72.9215829464286 ), Inc( 10 ), Minor Ticks( 1 )}
)
)
);
rpt = Current Report();
rpt[framebox( 1 )] << Add Graphics Script(
2,
Description( "" ),
Pen Color( "red" );
Y Function( x, x );
);

Re: Graph Builder y=x Line Not Tied to Specific GraphThanks @hogi and @txnelson . Once again you guys have come to the rescue.
@hogi Unfortunately I work on a Mac and it doesn't look like your add-in works on a Mac. It's too bad. It looks great.
@txnelson (or actually either of you...) I have a question about the Add Graphics Script command you used which is the same syntax as the generated JMP script. If it doesn't get too far into the weeds, what is the purpose of the 2 argument? The documentation on the Add Graphics Script command is very sketchy.
Thanks again.
Re: Graph Builder y=x Line Not Tied to Specific GraphIt is the position of the script, so you can force the order in which they are drawn
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(
1,
Fill Color("Red");
Circle(
20,
{20, 20},
{50, 50},
{70, 80},
"FILL"
)
);
Report(gb)[FrameBox(1)] << Add Graphics Script(
2,
Circle(
20,
{40, 20},
{40, 50},
{40, 80},
"FILL"
)
);
Like you see in customize menu

Edit: Specify the Order of Graphical Elements (jmp.com)
Re: Graph Builder y=x Line Not Tied to Specific Graph
@hogi wrote:
great idea - I use it sooo often!
-> I will add it to Graph Builder Toolbar : )
available now:
