cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to set a Reference Line on each page with Page option in Graph Builder?

The following script plots some charts with the page option in graph builder? How to I set a horizontal reference line, for each chart, say at Weight = 80Kg and label it (80kg) using JSL?

(I need the reference line to remain even if there is a change in the number of charts plotted)

Names Default To Here(1); 
dt = open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Size(528, 2954),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight), Page(:age)),
	Elements(Points(X, Y, Legend(15)), Smoother(X, Y, Legend(16)))
);
When it's too good to be true, it's neither
6 REPLIES 6

Re: How to set a Reference Line on each page with Page option in Graph Builder?

Names Default To Here(1); 
dt = open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Size(528, 2954),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight), Page(:age)),
	Elements(Points(X, Y, Legend(15)), Smoother(X, Y, Legend(16)))
);

axis = gb << XPath( "//AxisBox" );
Summarize( page = By( :age ) );
axis[2::(2*NItems( page ))::2] << Add Ref Line( 80, "Solid", "Red", "Reference" );
Neo
Neo
Level VI

Re: How to set a Reference Line on each page with Page option in Graph Builder?

@Mark_Bailey  Stops working for me (JMP 16.2) if I invoke Local Data Filter on Age after plotting, as below

Neo_0-1726153593695.png

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to set a Reference Line on each page with Page option in Graph Builder?

Easiest way is to add new column to your data table with same value for each of the rows and add that to your graph. This will work with filters

-Jarmo
Neo
Neo
Level VI

Re: How to set a Reference Line on each page with Page option in Graph Builder?

@jthi your suggestion works fine, except that I would like the line label to be on the right. Is there a way to change the location of the line label?

When it's too good to be true, it's neither
jthi
Super User

Re: How to set a Reference Line on each page with Page option in Graph Builder?

I don't remember which options are available in JMP16 as I'm mostly using JMP18 nowadays (with some JMP17 mixed in)

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << New Column("Ref", Numeric, Continuous, Set Each Value(80));

gb = dt << Graph Builder(
	Size(528, 984),
	Show Control Panel(0),
	Variables(X(:height), Y(:weight), Y(:Ref, Position(1)), Page(:age)),
	Elements(
		Points(X, Y(1), Legend(15)),
		Smoother(X, Y(1), Legend(16)),
		Line(Y(2), Legend(17))
	),
	Local Data Filter(
		Add Filter(
			columns(:age),
			Where(:age == {12, 15}),
			Display(:age, N Items(6))
		)
	),
	SendToReport(
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				17,
				Level Name(0, "Ref", Item ID("Mean(Ref)", 1)),
				Properties(
					0,
					{Line Label Properties(
						{Name Label(1), Name Label Position("Last")}
					)},
					Item ID("Mean(Ref)", 1)
				)
			)}
		)
	)
);

Write();

jthi_0-1726163173773.png

 

-Jarmo
hogi
Level XI

Re: How to set a Reference Line on each page with Page option in Graph Builder?

No need to change the data table.

Replicating the axis setting via

Link Page Axes( "Y Only" )

copies the reference lines as well.

e.g.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Link Page Axes( "Y Only" ),
	Variables( X( :height ), Y( :weight ), Page( :sex ), Overlay( :sex ) ),
	Elements( Points( X, Y), Smoother( X, Y) ),
	SendToReport(
		Dispatch( {}, "weight", ScaleBox,
			{Add Ref Line( 100, "Solid", "Black", "", 1 )}
		)
	)
);

 

hogi_0-1726169228867.png