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!
Choose Language Hide Translation Bar
Highlighted
Level I

## two plots on one graph

Hi all - I'm new to JMP's graph builder. I'm sure this is easy but alas...

I need to present two plots on one graph:
1. bars with s.e. bars (mean long-term rainfall by month)
2. line (no error bars) rainfall data from a single year, also by month

So, same x and same y axes.

Thanks in anticipation.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff

## Re: two plots on one graph

Hi Malurus,

You are on the right track here. Once you add the two variables to the y-axis, the trick is to use both the Bar and Line graphing elements. (drag and drop the 2nd element onto graph)

From there, modify which variable (current or historical rainfall) applies to which graphing element. To do this:

From lefthand panel, expand the Variables menu

Select historical for the Line element

Select current for the Bar element

You can also add the SE bars for the Bar element via this panel

You should end up with something like the image below (lefthand panel items indicated in red):

6 REPLIES 6
Highlighted

## Re: two plots on one graph

Malurus,

Can you give us a bit on where you're getting stuck?

You may have more luck with the Overlay plot platform, which lets you plot two y-variables with the same x variable.
Highlighted
Level I

## Re: two plots on one graph

Thanks Eugene,
Here is the work flow (keeping the rainfall example going):
1) drag month onto x
2) drag long-term rainfall data on y
3) right click points -> change to bar
4) right click bar -> add -> error bars -> standard error
So far so good. But, this is where I get stuck:
5) drag rainfall data from a single year (the one I want to be represented by a line) onto the y axis and it displays as a second bar series, (and also adds error bars of 0)
6) if I right click on the second series -> bar -> change to line, both series get changed to line
So my question is how do I change just one series to line (with no se bars), while keeping the other as bars (with se bars)?
Highlighted
Super User

## Re: two plots on one graph

I cannot find a way to do it mannually but it seems to be possible via script. Try this (change to your own column names):

``````Graph Builder(
Variables( X( :Month ), Y( :MeanRainfall ), Y( :Rainfall, Position( 1 ) ) ),
Elements(
Bar(
X,
Y( 1 ),
Legend( 3 ),
Row order( 0 ),
Error Bars( "Standard Error" ),
Summary Statistic( "Mean" )
),
Line(
X,
Y( 2 ),
Legend( 3 ),
Row order( 0 ),
Error Bars( "Standard Error" ),
Summary Statistic( "Mean" )
)
)
);``````
Highlighted
Level I

## Re: two plots on one graph

Thanks MS - I appreciate your suggestion.

I tried using your script after altering the column names and couldn't get it to work. But I'm not good with scripts, nor do I have the time to learn how to work with them - if I did I'd be using R!

I'm surprised JMP can't do this - it's not a complicated request and it's fairly routine for programmes like Sigmaplot.

C'mon JMP people! I've got 23 days left on my eval licence and things don't look good for you right now if I have to resort to learning how to use scripts.
Highlighted
Super User

## Re: two plots on one graph

Graph builder is a "quick and dirty" way to rapidly explore data graphically. Use the "Chart" platform if you want to make this combined plot manually.

Enter Month and your two Y variables, and make sure "Overlay" is checked and also check "Add error bars to mean". In the legend of the resulting graph, right-click on one variable and change to "Line chart".

And, btw, the scripting in JMP is what sets it apart. You don't have to learn much actual scripting (like in R). Most of the things you do manually can be saved as a script for repeated use. Yet, JMP scripting, can be very powerful.

But if it's just neat graphs you are looking for, JMP may not be for you.
Highlighted
Staff

## Re: two plots on one graph

Hi Malurus,

You are on the right track here. Once you add the two variables to the y-axis, the trick is to use both the Bar and Line graphing elements. (drag and drop the 2nd element onto graph)

From there, modify which variable (current or historical rainfall) applies to which graphing element. To do this:

From lefthand panel, expand the Variables menu

Select historical for the Line element

Select current for the Bar element

You can also add the SE bars for the Bar element via this panel

You should end up with something like the image below (lefthand panel items indicated in red):

Article Labels

There are no labels assigned to this post.