turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Adding error bars in JMP

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 9, 2012 8:04 AM
(9998 views)

Hi guys, I have a simple problem which I have been unable to solve. I have a dataset which I would like to plot in a Fit Y by X style scatterplot against another dataset. For each datapoint I know the standard deviation and I would like to add these standard deviations as error bars to the plot, is there anyway to do this?

It seems like JMP only does this normally if it has calculated the standard deviation itself, I don't want this as I already know the standard deviation for each and every datapoint.

Thanks for any help

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 7, 2012 12:22 PM
(10570 views)

Solution

It's possible to use Graph Builder to show error bars without stacking the data. I.e. you have 3 separate columns: center point, upper limit and lower limit. Using the data above, you drag the X variable (age) to the X axis. Then highlight upper and lower and drag them to the Y axis. Right click in the center of the graph, click Points > Change to > Bar. Then right click in the graph, click Bar > Bar Style > Interval. Now drag the column Mean(height) just to the right of the Y axis. Next add connecting lines and remove the connecting lines for upper and lower.

Here's a JSL script that does it, along with some formatting:

// Make an example table

dt = Open**(** "$ENGLISH_SAMPLE_DATA/Big Class.jmp" **)**;

dtsum = dt << Summary**(** Group**(** :age **)**, Mean**(** :height **)**, Std Err**(** :height **)** **)**;

// Add columns with Mean ± SE

dtsum << New Column**(** "lower", numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** –

**(**:Name**(** "Std Err(height)" **)** << get as matrix**)**

**)**

**)**;

dtsum << New Column**(** "upper",

numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** +

**(**:Name**(** "Std Err(height)" **)** << get as matrix**)**

**)**

**)**;

Graph Builder**(**

Show Control Panel**(** **0** **)**,

Variables**(**

X**(** :age **)**,

Y**(** :lower **)**,

Y**(** :upper, Position**(** **1** **)** **)**,

Y**(** :Name**(** "Mean(height)" **)**, Position**(** **1** **)** **)**

**)**,

Elements**(**

Bar**(**

X,

Y**(** **1** **)**,

Y**(** **2** **)**,

Y**(** **3** **)**,

Legend**(** **2** **)**,

Bar Style**(** "Interval" **)**,

Summary Statistic**(** "Mean" **)**

**)**,

Line**(** X, Y**(** **3** **)**, Legend**(** **4** **)**, Row order**(** **0** **)**, Summary Statistic**(** "Mean" **)** **)**

**)**,

SendToReport**(**

Dispatch**(**

**{}**,

"400",

ScaleBox,

**{**Legend Model**(**

**2**,

Properties**(** **0**, **{**Line Color**(** **0** **)}** **)**,

Properties**(** **1**, **{**Line Color**(** **0** **)**, Marker**(** "FilledCircle" **)}** **)**

**)}**

**)**,

Dispatch**(** **{}**, "Graph Builder", FrameBox, **{**Marker Size**(** **3** **)}** **)**

**)**

**)**;

9 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 9, 2012 3:06 PM
(5626 views)

It is possible but I have not found a straightforward way to do it. First you need to calculate mean-SE and mean+SE. Then you'll get the best result if you first stack the columns. Try the script below. It illustrates some ways to do it in JMP 9.

// Make an example table

dt = Open**(** "$ENGLISH_SAMPLE_DATA/Big Class.jmp" **)**;

dtsum = dt << Summary**(** Group**(** :age **)**, Mean**(** :height **)**, Std Err**(** :height **)** **)**;

// Add columns with Mean ± SE

dtsum << New Column**(** "lower",

numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** - **(**:Name**(** "Std Err(height)" **)** << get as matrix**)**

**)**

**)**;

dtsum << New Column**(** "upper",

numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** + **(**:Name**(** "Std Err(height)" **)** << getasmatrix**)**

**)**

**)**;

// Stack columns

dtstacked = dtsum << Stack**(**

columns**(** :Name**(** "Mean(height)" **)**, :lower, :upper **)**,

Source Label Column**(** "Label" **)**,

Stacked Data Column**(** "Data" **)**,

Name**(** "Non-stacked columns" **)(**Keep**(** :age **))**

**)**;

// Three ways to make a graph with mean and error bars based known SE

// 1. Overlay plot with range plot. Ugly graph and markers are visible for ± SE

dtsum << Overlay Plot**(** X**(** :age **)**, Y**(** :Name**(** "Mean(height)" **)**, :lower, :upper **)**, Range Plot**(** **1** **)** **)**;

// 2. Graph builder. Nicer graph but table must be stacked first.

dtstacked << Graph Builder**(**

Show Control Panel**(** **0** **)**,

Variables**(** X**(** :age **)**, Y**(** :Data **)** **)**,

Elements**(**

Points**(**

X,

Y,

Legend**(** **0** **)**,

Jitter**(** **0** **)**,

Summary Statistic**(** "Mean" **)**,

Error Bars**(** "Range" **)**,

**)**

**)**

**)**;

// 3. Chart platform. Similar to graph in 2.

dtstacked << Chart**(**

X**(** :age **)**,

Y**(** Mean**(** :Data **)** **)**,

Add Error Bars to Mean**(** Range **)**,

Overlay Axis << **{{**Min**(** **52.5** **)**, Max**(** **72.5** **)**, Inc**(** **5** **)**, Minor Ticks**(** **1** **)}}**,

Y**[****1****]** << Point Chart**(** **1** **)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 7, 2012 12:22 PM
(10571 views)

It's possible to use Graph Builder to show error bars without stacking the data. I.e. you have 3 separate columns: center point, upper limit and lower limit. Using the data above, you drag the X variable (age) to the X axis. Then highlight upper and lower and drag them to the Y axis. Right click in the center of the graph, click Points > Change to > Bar. Then right click in the graph, click Bar > Bar Style > Interval. Now drag the column Mean(height) just to the right of the Y axis. Next add connecting lines and remove the connecting lines for upper and lower.

Here's a JSL script that does it, along with some formatting:

// Make an example table

dt = Open**(** "$ENGLISH_SAMPLE_DATA/Big Class.jmp" **)**;

dtsum = dt << Summary**(** Group**(** :age **)**, Mean**(** :height **)**, Std Err**(** :height **)** **)**;

// Add columns with Mean ± SE

dtsum << New Column**(** "lower", numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** –

**(**:Name**(** "Std Err(height)" **)** << get as matrix**)**

**)**

**)**;

dtsum << New Column**(** "upper",

numeric,

values**(**

**(**:Name**(** "Mean(height)" **)** << get as matrix**)** +

**(**:Name**(** "Std Err(height)" **)** << get as matrix**)**

**)**

**)**;

Graph Builder**(**

Show Control Panel**(** **0** **)**,

Variables**(**

X**(** :age **)**,

Y**(** :lower **)**,

Y**(** :upper, Position**(** **1** **)** **)**,

Y**(** :Name**(** "Mean(height)" **)**, Position**(** **1** **)** **)**

**)**,

Elements**(**

Bar**(**

X,

Y**(** **1** **)**,

Y**(** **2** **)**,

Y**(** **3** **)**,

Legend**(** **2** **)**,

Bar Style**(** "Interval" **)**,

Summary Statistic**(** "Mean" **)**

**)**,

Line**(** X, Y**(** **3** **)**, Legend**(** **4** **)**, Row order**(** **0** **)**, Summary Statistic**(** "Mean" **)** **)**

**)**,

SendToReport**(**

Dispatch**(**

**{}**,

"400",

ScaleBox,

**{**Legend Model**(**

**2**,

Properties**(** **0**, **{**Line Color**(** **0** **)}** **)**,

Properties**(** **1**, **{**Line Color**(** **0** **)**, Marker**(** "FilledCircle" **)}** **)**

**)}**

**)**,

Dispatch**(** **{}**, "Graph Builder", FrameBox, **{**Marker Size**(** **3** **)}** **)**

**)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 12, 2012 9:00 AM
(5626 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 30, 2012 8:47 AM
(5626 views)

This is really useful but how do you remove the connecting lines for upper and lower (other than by scripting)?

Thanks,

Phil

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 30, 2012 9:50 AM
(5626 views)

**Line > Y > upper** (or whatever you called your upper bound column). Repeat for the lower bound.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 31, 2012 3:11 AM
(5626 views)

Brilliant. I did not realise that is was that simple.

Thanks.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 4, 2016 11:40 AM
(5626 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 5, 2016 5:07 AM
(5626 views)

There is an add-in from Ian Cox that might be what you are looking for.

JMP Add-In that plots uncertainty in X and Y values

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

3 weeks ago
(489 views)