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


Publication date: 04/30/2021

Add a Legend

To add a legend to a graph, send the Row Legend message to the frame box. In the Row Legend message, specify which column you want to base the legend on and whether the legend affects colors and markers.

For example, using Big Class.jmp, submit the following JSL to turn on a legend based on the age column. Set both colors and markers by values in the age column.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( y( :height ), x( :weight ) );
rbiv = biv << Report;
framebox = rbiv[Frame Box( 1 )];
 

/* make a legend with the "age" title

display colors and markers in the legend */

framebox << Row Legend( "age", Color( 1 ), Marker( 1 ) );

The Color() and Marker() arguments are optional. Colors are on and markers are off by default.

To use a continuous scale if your variable is nominal or ordinal, you can use a continuous color theme with the Continuous Scale( 1 ).

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( y( :weight ), x( :height ) );
rbiv = biv << Report;
framebox = rbiv[Frame Box( 1 )];
framebox << Row Legend( "age", Color( 1 ), Continuous Scale( 1 ) );

To interactively add a legend, right-click the graph, select Row Legend, and change the column settings.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).