BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar



Jun 23, 2011

Vector Plots in JMP

Vector plots show arrows on a two-dimensional plot and allow one to see four dimensions of data: x position, y position, arrow angle, and arrow length. Equivalently, the four dimensions can be x start position, y start position, x end position, and y end position. The latter form is most convenient for JMP. Though JMP doesn't have a menu command to create vector plots, arrows can be added to almost any plot without much trouble.

While lots of four-variable data sets can be adapted for vector display, I'll demonstrate with one of the most natural applications: wind data. This data set records wind speed and direction for various weather stations in the Chicago area. I used formulas to convert the speed and direction into end positions for the arrows and then added the following graphics script to a bivariate scatterplot using Customize from the graph's right-click menu.

Pen Size( 2 );

For Each Row( Arrow( {lon1, lat1}, {lon2, lat2} ) );

Here's a screen capture showing a little bit of the data table, graph, and customize dialog:

The next steps were to delete the rows with no wind and to turn off the points in the graph.

To provide context, I added the map of weather stations provided by the weather service. Placing a image in a graph is a bit tricky (and could be the subject of another post). There are two options: Draw the picture in another custom graphics script, or drag and drop an existing image into the graph. I chose the latter since I had an image file. First, I sized the graph to be the same size as the image, and then I dragged the image file into the center of the graph. After a few tries, the alignment was pretty good. (BTW, we're working on making this better in JMP 9.)

The plot shows relative wind readings taken at 6 p.m. on May 31, 2009. With the help of the background image, we can see how wind patterns vary in relation to Lake Michigan.

UPDATE 10/6/09: The data file, with scripts, is now available in the JMP File Exchange. Look for the file called "" in the Data Visualization section.

Source of data and image: the National Severe Storms Laboratory Historical Weather Data Archives, Norman, Oklahoma.

Community Member

DaveG wrote:


note for readers - in JMP 9 you can take this script and add a background US map. Right click on the graph to customise, and select the US states map.



Community Member

Xan Gregg wrote:

Very nice -- that gives five dimensions of data, now.

The background image is discussed a little in the blog post. I dragged a PNG file in manually; unfortunately, it's not currently scriptable.

Community Member

Karen wrote:

Thanks Xan,

Very interesting and easy to follow. I didn't know you could add a script to a graph like that. I played with the examples and added the Pen Color line so that the arrow now takes its color from the table. Then i added a legend to the graph so it would color the rows by temperature and you end up with pretty colored arrows AND points.

How do you get the picture in the background in the screenshot on your blog?


Y( :Lat1 ),
X( :Lon1 ),
"Bivar Plot",
{Frame Size( 501, 429 ),
Add Graphics Script(
Description( "Script" ),
For Each Row(
Pen Color( Color Of( Row State() ) );
Pen Size( 2 );
Arrow( {:Lon1, :Lat1}, {:Lon2, :Lat2} );
), Row Legend(
Color( 1 ),
Color Theme( "Blue to Gray to Red" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 1 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )



Community Member

Xan Gregg wrote:

I uploaded the data file to the File Exchange under the name "". It includes scripts that draw the plot with vectors.

Community Member

Karen wrote:

Hi Xan,

Can I get a copy of your vectorplot table with script? I would like to understand this capability better.



Community Member

Nishant Thakur wrote:

Hi, I am Nishant.I am trying this script but only Lat1 and Lon1 are getting plotted on graph. How should I plot Lat2 and Lon2 on same graph. Would you please guide me?


Xan Gregg wrote:

Did you add the custom script? That's what pulls in Lat2 and Lon2. You might try the script from Karen's comment above for a complete solution, and then work backwards to see how it differs from yours.

Community Member

Daryl Purcell wrote:

Is it possible to draw/append a line from the tip of one vector to another. would be very useful in residual analysis applications where user is interested in shape. Let me know. Thanks!


Xan Gregg wrote:

Of course you can do anything by modifying the script :). For instance, to operate on single x and y column, replace the Arrow command with something like If(row() > 1, Arrow({x[row()-1], y[row()-1]}, {x, y})).

Even without modifying the script, you can get the effect by chaining the x/y values in the table. That is, x1,y1 of row n would be the same as x2,y2 from row n-1.

Community Trekker

Hello Xan,


I was wondering if you can suggest an efficient way to apply the arrows to multiple bivariate fit graphs (grouped by some other column).  For example, if I had multiple days worth of 'ChicagoWind' data and wanted to plot several bivariate charts by each date and apply the arrows by date.  Is there an easier way to do this rather than building a loop for each date?


Thank you,



Community Member