For the latest version of JMP Help, visit JMP.com/help.


Publication date: 05/05/2023

Graph Builder Scripts

The following is an example of the basic structure of a Graph Builder script:

Graph Builder(
Size( x, y ),
// Use any commands from the red triangle menu - Size is an example
Variables( role( column ), ...), //Required
Elements( element name( element options, ...), //Required
Data Filter( ... ),
// Use any display customizations here - Data Filter is an example
);

The following is an example of a simple Graph Builder script that creates a bar chart:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Graph Builder(Variables(
	X( :age ),
	Y( :weight ) ),
Elements( Bar( X, Y, Legend( 8 ) ) )
// Legend is not required, but provides an internal legend ID that you can use for later customization
);

The following is a more detailed Graph Builder script that creates a bar chart:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Graph Builder(
Size( 373, 332 ),
Show Control Panel( 0 ),
Variables(
	X( :age ),
	Y( :weight ),
	Y( Transform Column( "weight25",
			Formula( Col Quantile( :weight, 0.25, :age ) )
			),
		Position( 1 )
/* By default each Y variable gets its own axis, but the Position(1)
option keeps each additional Y in the first slot and merges the axes. */
	),
	Y( Transform Column( "weight75", Formula( Col Quantile( :weight, 0.75, :age ) ) ),
		Position( 1 )
	)
),
Elements(
	Bar( X, Y( 2 ), Y( 3 ), Legend( 10 ), Bar Style( "Range" ) ),
// This bar element uses only the second and third Y variables and
// draws a Range bar between the values.*/
	Bar( X, Y( 1 ), Legend( 8 ),
		Bar Style( "Float" ), Summary Statistic( "Median" )
// This bar element uses the first Y variable and draws its median with the
// float style, which is a short horizontal line
	),
	Points( X, Y( 1 ), Legend( 9 ) )
// The Points element shows the raw data as markers.
),
SendToReport(
// Contains display customizations
	Dispatch( {}, "400", ScaleBox,
// 400 is the fixed name
		{Legend Model( 10,
		Level Name( 0, "1st to 3rd
		quartiles",
		Item ID( "Mean(weight25)..Mean(weight75)", 1 )
// Renames the legend, moves the legend name onto several lines, and changes
// the color for legend 10 (the Range bar)
	),
		Properties( 0, {Fill Color( 32 )},
		Item ID( "Mean(weight25)..Mean(weight75)", 1 )
// Changes the color for legend 10 (the range bar)
	)
		), Legend Model( 9,
		Properties( 0, {Marker Size( 4 )}, Item ID( "weight",1 ) )
// Changes the marker size for legend 9 (the Points element)
	)}
),
Dispatch( {}, "graph title", TextEditBox,
	{Set Text( "Weights with quartile ranges" )}
// Changes the graph title
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "weight" )} ),
// Changes the Y axis title
Dispatch( {}, "400", LegendBox,
// Hides the legend item for legend 9 by giving it a position of -1
	{Legend Position( {10, [0], 8, [1], 9, [-1]} )}
	)
)
);
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).