Monday, November 9. 2009
JMP scripting is an important part of the JMP user experience. Anyone can easily create a reusable JMP "program" with JMP Scripting Language (JSL) by running an analysis, selecting the hotspot (red triangle) at the top of the report, and choosing "Script." From there, you can save a script to a data table, a script window, a journal, or a project.
But did you know that you can also write a script that can create or modify a data table? To see a script that creates a data table, follow these steps:
a) Open a data table in JMP.
b) Open a script window (File->New->Script).
c) In the script window, type Current Data Table() << get script; and run this script (Cntl-R or Edit->Run Script).
d) Open the JMP log (View->Log). In the JMP log, the script that recreates the data table is shown.
e) Copy and paste that script where you need it to go.
An example screenshot of what this process produces is shown below.
I tend to do this a lot, especially when I am preparing presentations using custom journals or when I need a starting version of a data table for a more complicated script. The multi-step process is tedious, so naturally, I wondered if I could write a JMP script that would automate that process. It turns out that it was a pretty simple script.
The JSL is below, and the script file is available for download from the JMP File Exchange.
// Save the script to a global variable
tblScript = Current Data Table() << Get Script;
// Create an empty script box object
scrBox = Script Box();
//You want the text version of tblScript, which
// is an expression. Char turns it into text.
//Name Expr returns the unevaluated expression
scrBox << Set Text(
Char(
Name Expr(tblScript)
)
);
//The script displays in a report window (note the icon
//in the upper left), but can be executed like a script.
newScrWind = New Window(
"Script for Current Data Table",
scrBox
);
// resize the window
newScrWind << Size Window(800,600);
// reformat the script
scrBox << Reformat;
Monday, October 26. 2009
Today is a special day for a colleague. Happens every 365 days.
A good friend here is 1388534400 today. At least that's what JMP tells me when I put her birthday in one column and today's date in another and then calculate the difference.
You see, JMP stores dates as the number of seconds since midnight on January 1, 1904. So today's date, October 26, 2009, is 3339360000 as far as JMP is concerned.
Fortunately, JMP has a host of built-in functions to help deal with dates in this format. See the whole list in the Formula Editor under the Date Time category.
One very helpful class of these functions are the In XXX() functions where XXX is a time unit. These functions return the number of seconds in the time unit specified. For example, In Minutes(1) returns 60. That is, there are 60 seconds in 1 minute.
These functions come in handy for converting JMP's seconds-based dates to something more readable, like years. You do that by dividing a number of seconds by In Years(1):
To save my friend's dignity, I'll let you use that formula to figure out how old she is.
I hope that she has a great day.
Thursday, July 16. 2009
While Lou Valente, Scott Wise and I were presenting the Lowering Costs Through Visual Analytics seminar at the SAS Austin campus recently, one of the attendees gave us a great hint. Fred Norton of Fred Norton LLC – a facility consulting firm – told us that there was an easy way to embed a JMP Flash file into a PowerPoint presentation.
Fred had discovered freeware from iSpring that can convert a PowerPoint file into a Flash file. This software also lets you easily embed Flash files into a PowerPoint file. I have found that saving the output as PowerPoint (PowerPoint 2003) works best. You don’t need to send the original file when sharing the slide show.
Here are some instructions:
1. In JMP, save your Profiler or Bubble Plot as Flash.
2. Download iSpring Free Flash converter from http://www.ispringsolutions.com/products/ispring_free.html.
3. Launch either iSpring or PowerPoint.
4. iSpring will show up as a PowerPoint add-in.
5. Make sure a blank slide is showing in PowerPoint or change layout as necessary.
6. Launch Insert Flash tab from iSpring and insert your Flash file.
7. Resize object and or create additional labeling.
8. Launch slide show to confirm.
9. Save file.
10. E-mail it to such people as your boss, co-worker or favorite client, telling them to launch the slide show so that they can tweak the inputs of the Profiler or see an animated time series with the Bubble Plot.
Fred also mentioned that he felt that saving the Profiler as a Flash file was a little confusing at first. So I thought I’d give a simple description for others who also found it confusing. From Fit Model, save the prediction formula to a column (this option is found under Save Columns under the top red triangle). In Neural Net, save the profile formula. Then select Profiler from the Graph pull-down menu and put that formula column into the Y box. No other variables are needed. The top red triangle in the resulting graph gives you the option to save as Flash. There is no need to create a companion HTML file.
Monday, June 15. 2009
The list is one of the basic building tools for organizing data in JSL. The power of lists is that they can contain any kind of items (numbers, characters, other lists, ...), and they can grow and shrink as needed. However, if you just need a fixed list of numbers, you can get much better performance from a one-dimensional matrix.
Consider these two samples that make arrays of odd numbers.
// make a list of odd numbers
n = 1000;
y = {};
for (i = 1, i <= n, i++,
y[i] = 2 * i - 1;
);
y[n];
// make a matrix of odd numbers
n = 1000;
y = J(1, n); // creates a 1 x n matrix with all values set to 1
for (i = 1, i <= n, i++,
y[i] = 2 * i - 1;
);
For a few hundred items, there's not much difference. But as n goes beyond 1000 (or if the above code is in a loop), you start to notice the difference in speed. For lists, there is a certain amount of overhead for growing dynamically and general flexibility.
Notice the J function can be used to create a new matrix of a given size. Jm,n is the name for the Unit Matrix in linear algebra.
Also notice that a one-dimensional matrix can be indexed with just one subscript. That is, we can use y[i] instead of y[1][i]. That makes it easier to treat matrices as lists, and in the loop above, which is the same in both cases.
Question until next time: How can the code be made even faster?
Tuesday, June 9. 2009
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 "ChicagoWind.jmp" in the Data Visualization section.
Source of data and image: the National Severe Storms Laboratory Historical Weather Data Archives, Norman, Oklahoma.
Tuesday, March 24. 2009
In JMP 8, you may have noticed that you have access to more option for row markers. Do you need some help getting started? Here are a few pointers:
1. From your Start Menu in Windows, select Start -> Programs -> Accessories -> System Tools -> Character Map
2. Browse through the unique characters available under fonts like Wingdings and Webdings, which you can select from a pull-down menu at the top.
3. In JMP 8 under File -> Preferences -> Font, change the selection for Marker to the one you liked at the Character Map.
4. From here you have a few options:
a. With your data table open (here, I'm using Big Class from the Sample Data in JMP), have JMP select the marker by going to Rows->Color or Mark by Column, Select the column you’d care to mark by, and change Markers to Alphanumeric. At that point, JMP assigns the symbol for the Marker Font you selected in Preferences that corresponds to the associated letter of the alphabet (that is, A= 1st symbol, B=2nd symbol).
b. To assign a specific marker to a specific row/subset of rows, highlight those rows and right-click. Select Marker -> Custom. Now you can: (1) just use trial and error with your keyboard. (Remember, your keyboard preferences are now set to a different font so an A isn’t an A as far as the markers are concerned) or (2) using the Character Map set to your preferred font, highlight the character you want to use, hit select, and then copy. Back in JMP in the Custom Marker box, paste your selection (Ctrl-V in Windows); again, this will appear as a regular set of letters, so don’t worry.
c. Another option: Go to Rows->Color or Mark by Column, Select the column you’d care to mark by, and change Markers to Alphanumeric. Check the box to “Make Window with Legend” and “OK.” In your legend, you can right-click, select Markers -> Custom, and copy and paste symbols from your Character Map to change them one by one.
Monday, March 9. 2009
A customer recently compared JMP's very rich interface to the interface in a computer game. Specifically, she said that watching me use JMP was like watching her children play Super Mario Bros. Her boys would be guiding one of the Italian plumbers along, and suddenly they would stop and direct Mario or Luigi to leap into the air and, out of nowhere, a box full of gold coins would appear above his head.
Similarly, she said that the more she uses JMP, the more gold coin boxes she finds.
We've tried to put the most commonly used features prominently in the user interface, but many valuable, more advanced options are shown only with a right-click contextual menu, or only in a secondary dialog box. This is an attempt to make JMP's interface easier for the beginning user but provide options for the experienced user who wants more control and features.
Every now and then, I'll be posting tips and tricks to help show you where the gold coin boxes are. You may have found some of them already, but, to tell the truth, I find one I didn't know about most every day.
Too Many Axes to Grind
Today's tip comes from an interaction with the customer referenced above. She had a report window with dozens of graphs in it. It was created as the result of an analysis with a by-group column. So, most of the graphs used same column for the Y axis.
By default, JMP will set the minimum and maximum values on an axis to fit the data being plotted. When you use a by-group column, this results in the various graphs having different scales on the axes they have in common.
To make comparisons among the graphs easier, the customer wanted to rescale all of these axes to have the same scale. The day before we spoke, she had spent many hours double-clicking on each axis in the report and setting the minimum and maximum values in the resulting dialog. Then she discovered that she needed to re-do the analysis because the data had changed.
That's when she called me.
"There must be a quicker way," she said.
Indeed there is. A right-click on an axis will give you the an option to "Copy Axis Settings" to the clipboard as shown below.
Then, you can go to another axis and right-click on it and choose "Paste Axis Settings." Now, the two axes will match each other.
This alone would make the process of making axes have the same scale easier, but if you combine this with one more hidden gem, you'll get some real magic.
Instead of a simple right-click on the destination axis, hold the Ctrl key down as you right-click and choose "Paste Axis Settings." When you hold the Ctrl key down as you make changes in a report window, JMP will broadcast those changes to all similar objects in the window. So, as you paste the axis settings while holding the Ctrl key down, you'll paste them to all similar axes in the window.
What could be tedious becomes a breeze.
As I explained how to do this to this customer, I could almost hear the "boo-da-ling" of a coin box in the background.
|