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 )];
framebox << Row Legend( "age", Color( 1 ), Marker( 1 ) );
// make a legend with the "age" title
// display colors and markers in the legend
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.