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
ashwint27
Level III

Add reference lines-allowing ranges, by column variable- on separate pages in Graph Builder

I have several columns of numeric data, along with one numeric-continuous datetime column, to the nearest second.  I can plot any or all of these by datetime in a time-series to view simultaneously.  There is a "group" character-nominal column that in Graph Builder, I can use to separate the analysis by page.

 

There is another numeric-continuous date column "Event Date" that is to the nearest day (joined from another table) that is matched to each "group" value.  There would be one unique Event Date value for a given "group" variable.  I would like to automate or script adding reference lines from the "Event Date" column to the x-axis, however with "Allow Ranges", setting the Min Value as the Event Date at 12:00:00AM, and Max Value as the Event Date at 11:59:59 PM based on the "group" column variable, with the intent each "group" would go on a separate page.  Below is an example of what it would look like on one page, along with the typical Reference Line dialog box in Axis Settings in Graph Builder for reference:

ashwint27_5-1722468506063.png

 

ashwint27_3-1722468130842.png

 

 

 

4 REPLIES 4
txnelson
Super User

Re: Add reference lines-allowing ranges, by column variable- on separate pages in Graph Builder

If you select  to use a Dialog to setup the Graph Builder

txnelson_0-1722476977745.png

You can use a By() column rather than specifying it as a Page column.  When you do this, each displayed Graph Builder display output can have separate range reference lines 

txnelson_1-1722477139057.png

names default to here(1);
dt=
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	SendToByGroup( {:sex == "F"} ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
	By( :sex ),
	SendToByGroup(
		{:sex == "F"},
		SendToReport(
			Dispatch( {}, "weight", ScaleBox,
				{Add Ref Line(
					{100, 120},
					"Solid",
					"Medium Light Red",
					"",
					1,
					0.25
				)}
			)
		)
	),
	SendToByGroup(
		{:sex == "M"},
		SendToReport(
			Dispatch( {}, "weight", ScaleBox,
				{Add Ref Line(
					{140, 160},
					"Solid",
					"Medium Light Red",
					"",
					1,
					0.25
				)}
			)
		)
	)
);
Jim
ashwint27
Level III

Re: Add reference lines-allowing ranges, by column variable- on separate pages in Graph Builder

Thanks @txnelson.
This can work, but I'm wondering if instead of manually specifying the position of each By Group's reference lines, if I could call the Event Date column to set the reference line positions in some manner. Is that achievable?
jthi
Super User

Re: Add reference lines-allowing ranges, by column variable- on separate pages in Graph Builder

Could you share an example of your data / create a mockup data? There might be some a bit trickier methods in graph builder to achieve this without relying to scripting.

-Jarmo
txnelson
Super User

Re: Add reference lines-allowing ranges, by column variable- on separate pages in Graph Builder

Of course the reference ranges can be set based upon values within other columns, or from results from JMP platforms.  I was just illustrating a way to make the different levels of your Page column referenceable by changing to the use of a By().  Below is a simple expansion of the example I previously provided.  It sets the Reference Line range based upon the mean and std of the X axis column for each of the graphs

txnelson_0-1722506310410.png

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

// This example sets the range of the reference lines based upon the mean +- 1 std
// of the weight column for each level of the sex column

Summarize( dt, sexGroup = by( :sex ), means = Mean( :weight ), stds = Std Dev( :weight ) );

Eval(
	Eval Expr(
		Graph Builder(
			SendToByGroup( {:sex == "F"} ),
			Variables( X( :weight ), Y( :height ) ),
			Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
			By( :sex ),
			SendToByGroup(
				{:sex == "F"},
				SendToReport(
					Dispatch( {}, "weight", ScaleBox,
						{Add Ref Line(
							{Expr( means[1] - stds[1] ), Expr( means[1] + stds[1] )},
							"Solid",
							"Medium Light Red",
							"",
							1,
							0.25
						)}
					)
				)
			),
			SendToByGroup(
				{:sex == "M"},
				SendToReport(
					Dispatch( {}, "weight", ScaleBox,
						{Add Ref Line(
							{Expr( means[2] - stds[2] ), Expr( means[2] + stds[2] )},
							"Solid",
							"Medium Light Red",
							"",
							1,
							0.25
						)}
					)
				)
			)
		)
	)
);

JMP's scripting language(JSL) has the ability to do just about anything you envision you need to do.  I suggest that you take the time to read the Scripting Guide which will provide you with the knowledge of how to JSL can accomplish what you want.

Jim