Get more from Graph Builder: Points with error bars
Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Get more from Graph Builder: Points with error bars
Apr 15, 2014 8:40 AM
| Last Modified: Aug 20, 2017 1:42 PM
Error bars are a great way to visually show the variability in your data. They are often seen overlaid on top of bars and points, and a wide range of error bar views is available in Graph Builder in JMP.
To see what's possible, let's first build a bar chart using the “Car Physical Data” set from the JMP Sample Data files library. Upon opening Graph Builder, we add the continuous parameter “Gas Tank Size” to the left-hand y-axis and the categorical parameter “Type” to the bottom x-axis. Then we select the Bar icon from the top graph elements menu. Lastly, we go to the bottom left-hand statistics dialog box for Bar and select Mean under “Summary Statistic” and Standard Error under “Error Bars.” This presents a view like the one below. Note that in this graph, we also reduced the transparency of the bar shading so that you can see the error bars more easily when they are overlaid on top of the bars.
Graph Builder View 0: Error Bars on Top of Points
But what if we wanted to add error bars not to a bar chart, but instead to a display with points? This is an increasingly popular view that can give both a feel for the spread of the individual points as well as showing the added information of error bars. One way to do this is to take the same Graph Builder view we generated above and just change from the Bar to the Points icon from the top graph elements menu and ask again for Mean as “Summary Statistics”and Error Bars as “Standard Error.” However, as you can see in the graph below, we now lose the points and get only the error bars on the graph.
Graph Builder View 1: Point Error Bars
To create a graph with both error bars and points, we can add another points element from the top graph element menu and drag it down into the graph. Notice that it creates two Points dialog boxes in the left-hand graph statistics section. For the second Points dialog box, we can now select “Summary Statistic” as Mean and “Error Bars” as Standard Error. This presents a view as shown below. We again reduced the transparency of the points so you can see the error bars overlaid on the points better. (Note that another way of adding the second Points dialog is to right-click on the graph, select Add and then choose Points.)
Graph Builder View 2: Points & Error Bars Mixed
As you can see in the resulting graph, this visual is definitely not very easy to interpret as the error bars are buried within the points. An innovative solution to our problem would be to shift the error bars to the right of the points so we can see both easily on the same graph. We will explore three different ways to do this:
Solution 1: Use “label spacers” rows to enable side-by-side views of the points and error bars.
Solution 2: Create a “dummy variable” column in our data to create side-by-side views of the points and error bars.
Solution 3: Use JMP scripting to automate a custom view.
Solution 1: Add “Label Spacer” Rows
First, we add a new categorical column to our data called "Label." Then, we enter one label (in this case, “A”) for the entire column.
Then, we add 15 blank rows to the bottom of the data table and number them 1 through 15 on the label column. This column helps create space between the points and error bar visuals.
Table View 1: Data Table with “Label Spacers”
Now we create the graph by again bringing in two points elements into the graph and asking for points statistics on the first one and error bar statistics on the second.
We now space over the error bars on the graph by putting the “Label” column on the overlay. Notice how this shifts over the error bar to the left of the points, but maintains its orientation under the right x-axis label.
To clean up the view, we will also turn off the legend (from the top red-triangle menu) and un-jitter the points in the graph statistics area.
We need to create a dummy variable for our output by adding another output column and effectively doubling our data set size.
Then a label column creates separation on our graph. To clean up the view, we labeled the two label types “(“ or “)”.
Table View 2: Data Table with Dummy Variable
Next, we build the graph by bringing in both output columns and asking for points statistics on the first one and error bar statistics on the second.
Then, we create a nested label on the y-axis by bringing in the Label column to create the separation.
Graph Builder View 4: Error Bars via Dummy Variable
Solution 3: JMP Scripting for a Custom View
As the saying goes, “All things are possible with JMP JSL custom scripting!” Below is an example of a custom-scripted view with side-by-side points and error bars. This script does not do any table manipulation or dummy variable creation like the first two solutions. It manipulates the graph points themselves using scripting. So the end product lets us immediately generate our desired view with just the click of a button.
Graph Builder View 5: JMP Scripted Custom View
Whichever way you choose to create a graph with both points and error bars, it is easy to see how you can use the versatile Graph Builder platform (along with JMP scripting) to create new and exciting data visualizations!