cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
BHarris
Level VI

Create duplicate heat-maps with different summary statistics in Graph Builder

Given Big Class and this plot:

 

Graph Builder(
	Size( 574, 613 ),
	Graph Spacing( 20 ),
	Variables(
		X( :sex ),
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "Min" ) )
	),
	Elements( Position( 1, 1 ), Heatmap( X, Y, Legend( 4 ) ) ),
	Elements( Position( 2, 1 ), Heatmap( X, Y, Legend( 5 ) ) )
)

Is there a way to make the left plot use the "Mean" summary statistic and the right plot to use "Min"?

 

I tried adding another Color() specification but it doesn't seem to work in JMP 17.

2 ACCEPTED SOLUTIONS

Accepted Solutions
hogi
Level XII

Re: Create duplicate heat-maps with different summary statistics in Graph Builder


@BHarris wrote:

I tried adding another Color() specification but it doesn't seem to work in JMP 17.


-> add another color
Works with JMP 17 (.2)

hogi_0-1734716046947.png

 

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
Graph Builder(
	Size( 574, 613 ),
	Summary Statistic( "Median" ),
	Graph Spacing( 20 ),
	Variables(
		X( :sex ),
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "N" ) ),
		Color( :height, Summary Statistic( "Max" ) )
	),
	Elements( Position( 1, 1 ), Heatmap( X, Y, Color( 1 ), Legend( 4 ) ) ),
	Elements( Position( 2, 1 ), Heatmap( X, Y, Color( 2 ), Legend( 5 ) ) )
);

 

 

View solution in original post

BHarris
Level VI

Re: Create duplicate heat-maps with different summary statistics in Graph Builder

Excellent, that worked!  I think I was missing the extra X variable when I added the color spec.  It would be nice if GB supported this with the UI, but it already does so much...

 

Here's the final script I was looking for:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Size( 934, 824 ),
	Show Title( 1 ),
	Graph Spacing( 20 ),
	Variables(
		X( :sex ),
		X( :sex ),
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "Min" ) ),
		Color( :height, Summary Statistic( "Mean" ) ),
		Color( :height, Summary Statistic( "Max" ) )
	),
	Elements(
		Position( 1, 1 ),
		Heatmap( X, Y, Color( 1 ), Legend( 1 ), Label( "Label by Value" ) )
	),
	Elements(
		Position( 2, 1 ),
		Heatmap( X, Y, Color( 2 ), Legend( 2 ), Label( "Label by Value" ) )
	),
	Elements(
		Position( 3, 1 ),
		Heatmap( X, Y, Color( 3 ), Legend( 3 ), Label( "Label by Value" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Age vs. Sex, Colored on Height -- Min, Mean, Max" )}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {1, [0], 2, [-1], 3, [-1]} )}
		)
	)
)

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Create duplicate heat-maps with different summary statistics in Graph Builder

What I did was to 

  1. Use Tables=>Summary to create a new table with the mean and min statistics grouped by Sex and Age
  2. Use Tables=>Stack to stack the mean and min columns
  3. Run Graph Builder

txnelson_0-1734645323632.png

names default to here(1);

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

// Data table summary
// → Data Table( "Summary of Big Class grouped by age, sex" )
Data Table( "Big Class" ) << Summary(
	Group( :age, :sex ),
	Mean( :height ),
	Min( :height ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "stat" ),
	output table name( "Summary of Big Class grouped by age, sex" )
);

// Stack data table
// → Data Table( "Stack of Summary of Big Class grouped by age, sex (Mean, Min)" )
Data Table( "Summary of Big Class grouped by age, sex" ) <<
Stack(
	columns( :Mean, :Min ),
	Output Table( "Stack of Summary of Big Class grouped by age, sex (Mean, Min)" )
);

Graph Builder(
	X Group Edge( "Bottom" ),
	Variables( X( :sex ), Y( :age ), Group X( :Label ), Color( :Data ) ),
	Elements( Heatmap( X, Y, Legend( 4 ) ) )
);
Jim

Re: Create duplicate heat-maps with different summary statistics in Graph Builder

Another option is to create two graph builder reports and place them side by side in a custom report new window. You might want to re-title the graphs so it is clear that one is colored Min and Max. Here is a simple example:

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

hm1 = expr( dt << Graph Builder(
	Size( 235, 613 ),
	Show Control Panel( 0 ),
	Variables(
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "Min" ) )
	),
	Elements( Heatmap( X, Y, Legend( 1 ) ) ),
));

hm2 = expr( dt << Graph Builder(
	Size( 235, 613 ),
	Show Control Panel( 0 ),	
	Variables(
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "Max" ) )
	),
	Elements( Heatmap( X, Y, Legend( 1 ) ) ),
));

new window( "Two Heat Maps", 
	h list box( hm1, hm2 )
);
-Scott

Re: Create duplicate heat-maps with different summary statistics in Graph Builder

At the risk of over-engineering this solution, you could generalize this for a list of stats.

 

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

statList = { "Mean", "Median", "Mode", "Min", "Max", "Range", "Median", "Std Dev" };

hm_fxn = function( { STAT },
	dt << Graph Builder(
		Size( 200, 300 ),				// Adjust size based on number of heatmaps
		Show Control Panel( 0 ),
		Variables(
			X( :sex ),
			Y( :age ),
			Color( :height, Summary Statistic( STAT ) )
		),
		Elements( Heatmap( X, Y, Legend( 1 ) ) ),
		SendToReport(
			Dispatch( {}, "Graph Builder", OutlineBox,
			{Set Title( "Color by " || STAT ), Image Export Display( Normal )}
			)
		)
	)
);

new window( "Heat Maps",
	outline box( dt << get name || " Heat Maps",
		lub = line up box( n col( 4 ) )	// Adjust n col() for number of heatmaps per row
	)
);

for each( { s }, statList,
	lub << append( hm_fxn( s ) )
)

 

scott_allen_0-1734700199705.png

 

-Scott
hogi
Level XII

Re: Create duplicate heat-maps with different summary statistics in Graph Builder


@BHarris wrote:

I tried adding another Color() specification but it doesn't seem to work in JMP 17.


-> add another color
Works with JMP 17 (.2)

hogi_0-1734716046947.png

 

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
Graph Builder(
	Size( 574, 613 ),
	Summary Statistic( "Median" ),
	Graph Spacing( 20 ),
	Variables(
		X( :sex ),
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "N" ) ),
		Color( :height, Summary Statistic( "Max" ) )
	),
	Elements( Position( 1, 1 ), Heatmap( X, Y, Color( 1 ), Legend( 4 ) ) ),
	Elements( Position( 2, 1 ), Heatmap( X, Y, Color( 2 ), Legend( 5 ) ) )
);

 

 

BHarris
Level VI

Re: Create duplicate heat-maps with different summary statistics in Graph Builder

Excellent, that worked!  I think I was missing the extra X variable when I added the color spec.  It would be nice if GB supported this with the UI, but it already does so much...

 

Here's the final script I was looking for:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Size( 934, 824 ),
	Show Title( 1 ),
	Graph Spacing( 20 ),
	Variables(
		X( :sex ),
		X( :sex ),
		X( :sex ),
		Y( :age ),
		Color( :height, Summary Statistic( "Min" ) ),
		Color( :height, Summary Statistic( "Mean" ) ),
		Color( :height, Summary Statistic( "Max" ) )
	),
	Elements(
		Position( 1, 1 ),
		Heatmap( X, Y, Color( 1 ), Legend( 1 ), Label( "Label by Value" ) )
	),
	Elements(
		Position( 2, 1 ),
		Heatmap( X, Y, Color( 2 ), Legend( 2 ), Label( "Label by Value" ) )
	),
	Elements(
		Position( 3, 1 ),
		Heatmap( X, Y, Color( 3 ), Legend( 3 ), Label( "Label by Value" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Age vs. Sex, Colored on Height -- Min, Mean, Max" )}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {1, [0], 2, [-1], 3, [-1]} )}
		)
	)
)