BookmarkSubscribeSubscribe to RSS Feed

## X,Y scatter plot with coloured zones

Community Trekker

Joined:

Jun 23, 2011

I am looking for a way to create a 2D scatter plot with 4 coloured zones for 4 rectangular quadrants of the plot area.  This is to quickly see visually which zone each plotted point falls within.  I could not find anything similar in JMP11, so any tips/hints scripts would be appreciated.

2 REPLIES

Staff

Joined:

Jun 23, 2011

You can use a graphics script to do this (see for example: http://www.jmp.com/support/help/Adding_Scripts_to_Graphs.shtml for how to do this 'by hand').

If you want to do it programmatically, you can tinker with the script below to get it the way you want. Cut and paste the code into an editor window, then select 'Edit > Run Script').

NamesDefaultToHere(1);

// Example data

dt = NewTable("Scatter PLot",

NewColumn("x", Numeric, Continuous, Formula(RandomNormal())),

NewColumn("y", Numeric, Continuous, Formula(RandomNormal())),

);

// Bivariate plot

biv = dt << Bivariate(X(:x), Y(:y));

xVals = Column(dt, "x") << getValues;

xMid = Quantile(0.5, xVals);

xDel = Max(Abs(Max(xVals) - xMid), Abs(xMid - Min(xVals)));

xMin = xMid - 100*xDel;

xMax = xMid + 100*xDel;

yVals = Column(dt, "y") << getValues;

yMid = Quantile(0.5, yVals);

yDel = Max(Abs(Max(yVals) - yMid), Abs(yMid - Min(yVals)));

yMin = yMid - 100*yDel;

yMax = yMid + 100*yDel;

// Tempate expression to add graphics script

ags =

Expr(

Report(biv)[FrameBox(1)] <<

1,

Transparency( 0.3 );

// Top left

Fill Color( "Red" );

Rect( xMinTBD, yMaxTBD, xMidTBD, yMidTBD, 1 );

// Top right

Fill Color( "Green" );

Rect( xMidTBD, yMaxTBD, xMaxTBD, yMidTBD, 1 );

// Bottom left

Fill Color( "Blue" );

Rect( xMinTBD, yMidTBD, xMidTBD, yMinTBD, 1 );

// Bottom right

Fill Color( "Black" );

Rect( xMidTBD, yMidTBD, xMaxTBD, yMinTBD, 1 );

);

);

// 'Bake in' values for this data to this expression

SubstituteInto(ags,

Expr(xMinTBD), xMin,

Expr(xMidTBD), xMid,

Expr(xMaxTBD), xMax,

Expr(yMinTBD), yMin,

Expr(yMidTBD), yMid,

Expr(yMaxTBD), yMax,

);

// Add the graphics script

ags;

Community Manager

Joined:

Jun 23, 2011

Ian@JMP​ has a good idea.

Another option in JMP 12 is to use the new color and range options in the Axis specification dialog to do this.

Double click on the axis and then use the Allow Ranges and Color options in the Reference Lines section.

-Jeff

-Jeff