cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
scott1588
Level IV

Graph Builder y=x Line Not Tied to Specific Graph

I 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.

 

scott1588_0-1723148025895.png

 

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.

2 ACCEPTED SOLUTIONS

Accepted Solutions
hogi
Level XII

Re: Graph Builder y=x Line Not Tied to Specific Graph

great 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 );
			)

 

View solution in original post

txnelson
Super User

Re: Graph Builder y=x Line Not Tied to Specific Graph

This 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 );
);

txnelson_0-1723149033069.png

 

Jim

View solution in original post

6 REPLIES 6
scott1588
Level IV

Re: Graph Builder y=x Line Not Tied to Specific Graph

My 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.

hogi
Level XII

Re: Graph Builder y=x Line Not Tied to Specific Graph

great 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 );
			)

 

txnelson
Super User

Re: Graph Builder y=x Line Not Tied to Specific Graph

This 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 );
);

txnelson_0-1723149033069.png

 

Jim
scott1588
Level IV

Re: Graph Builder y=x Line Not Tied to Specific Graph

Thanks @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.

jthi
Super User

Re: Graph Builder y=x Line Not Tied to Specific Graph

It 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

jthi_0-1723177250263.png

 

Edit: Specify the Order of Graphical Elements (jmp.com) 

-Jarmo
hogi
Level XII

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:

hogi_0-1725395433421.png