# \[?\] Plot a left and a right axis with ListPlot?

**URL:** <https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [April 8, 2017, 6:21pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295 "2017-04-08T18:21:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilicza](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gilicza](https://community.wolfram.com/u/gilicza)\
**Post date:** [April 8, 2017, 6:21pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/1 "2017-04-08T18:21:04Z")

</div>

Dear Community,

Probably a very newbie question: how can I have a left (primary) , and a right (secondary) vertical axis simultaneously in a ListPlot chart? I would need it because the two series to be plotted have very different magnitudes.

Tx in advance  
Andras

---

<div class="post-metadata">

**Author:** ![josklaps1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/josklaps1/32/22044_2.png) [@josklaps1](https://community.wolfram.com/u/josklaps1)\
**Post date:** [April 8, 2017, 9:49pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/2 "2017-04-08T21:49:32Z")

</div>

Andreas,

What is your code so far ?

---

<div class="post-metadata">

**Author:** ![gilicza](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gilicza](https://community.wolfram.com/u/gilicza)\
**Post date:** [April 9, 2017, 8:27am UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/3 "2017-04-09T08:27:24Z")

</div>

Dear Jos,

I’ve summarized the results of a lengthy engineering calculation in a spreadsheet, CALCRESULTS.xlsx. I try to plot results with the attached notebook ListLinePlot.nb. I would like to combine pressureplot and flowresults within one chart, where pressures belong to the left axis, and flowresults belong to the right axis, because they are very different in magnitude. Timepoints are the same.

Tx in advance,  
Andras

---

<div class="post-metadata">

**Author:** ![josklaps1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/josklaps1/32/22044_2.png) [@josklaps1](https://community.wolfram.com/u/josklaps1)\
**Post date:** [April 9, 2017, 10:12pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/4 "2017-04-09T22:12:53Z")

</div>

Hi Andreas,

I assume this what you expected !

```
ClearAll["Global`"]

calcresults = 
  Import["D:\\En\\Mathematica_Stuff\\CALCRESULTS.xlsx", {"Data", 1}];
p1 = calcresults[[All, {1 , 2}]];
p2 = calcresults[[All, {1 , 3}]];
p3 = calcresults[[All, {1 , 4}]];
flowresults = calcresults[[All, {1 , 5}]]; 

pressureplot = ListLinePlot[{p1, p2, p3} 
  , PlotStyle -> {Green , Blue , Red} 
  , Frame -> {{True, None}, {True, True}}
  , FrameStyle -> Automatic
  , FrameTicksStyle -> {{None, 
     Red}, {Directive[FontColor -> Gray, White], None}}
  , PlotLegends -> 
   Placed[{"Pressure Col B", "Pressure Col C", "Pressure Col D"}, 
    Bottom]
  , PlotRangePadding -> 0
  , ImagePadding -> 40
  ]
flowplot = ListLinePlot[ 
  flowresults 
  , Frame -> {{None, True}, {None, None}}
  , FrameTicks -> All
  , FrameStyle -> Automatic
  , FrameTicksStyle -> {{None, 
     Blue}, {Directive[FontColor -> Gray, White], None}}
  , PlotRangePadding -> 0
  , ImagePadding -> 40
  , PlotLegends -> {Style["Flowplot", Blue]}
  ]
Overlay[{pressureplot, flowplot}]

```

 ![2-axisplot2.gif](https://global.discourse-cdn.com/wolfram/original/3X/5/2/52ffd73869f1f416a15ad0f260bdd544a8845e40.gif)

I hope this will help, see file attached !

Regards…Jos

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [April 10, 2017, 2:53pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/5 "2017-04-10T14:53:03Z")

</div>

[@Jos Klaps](http://community.wolfram.com/web/josklaps1) :  
Nice trick to do it using `Overlay` - of course! There is a more  
[“official solution”](http://https%20:%20//%20%20%20reference.wolfram.com/language/howto/%20%20%20GeneratePlotsWithTwoVerticalScales.html) (https : //  
[reference.wolfram.com/language/howto/](http://reference.wolfram.com/language/howto/)  
GeneratePlotsWithTwoVerticalScales.html) which is much more complicated.

Regards – Henrik  
[at0]: [http://community.wolfram.com/web/josklaps1](http://community.wolfram.com/web/josklaps1)

---

<div class="post-metadata">

**Author:** ![gilicza](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gilicza](https://community.wolfram.com/u/gilicza)\
**Post date:** [April 10, 2017, 4:44pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/6 "2017-04-10T16:44:29Z")

</div>

Dear Jos,

Wow, yes, this is exactly what I meant. Thank you very much 🙂 Overlay is the command, which I was not aware of.  
best regards  
Andras

---

<div class="post-metadata">

**Author:** ![gilicza](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gilicza](https://community.wolfram.com/u/gilicza)\
**Post date:** [April 11, 2017, 8:30am UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/7 "2017-04-11T08:30:35Z")

</div>

Dear Jos,

May I ask for a little more help? I tried to resize the combined Overlay plot by dragging its corner by the mouse, but it is not possible. No problem with the individual plots pressureplot and flowplot. Do you possibly have some idea how it could be done?

Tx in advance,  
best regards  
Andras

---

<div class="post-metadata">

**Author:** ![josklaps1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/josklaps1/32/22044_2.png) [@josklaps1](https://community.wolfram.com/u/josklaps1)\
**Post date:** [April 11, 2017, 9:54am UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/8 "2017-04-11T09:54:24Z")

</div>

Hi Andreas,

Play around with the function “ImageSize” in the indivudual plots.

Example: ImageSize-\>600 or ImageSize-\>1.1{500,350}

File updated with the a/m function !

Good luck,…Jos

---

<div class="post-metadata">

**Author:** ![gilicza](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gilicza](https://community.wolfram.com/u/gilicza)\
**Post date:** [April 11, 2017, 11:07am UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/9 "2017-04-11T11:07:11Z")

</div>

Dear Jos,

Perfect solution, thank you very much. Very kind of you 🙂

best regards

Andras

---

<div class="post-metadata">

**Author:** ![josklaps1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/josklaps1/32/22044_2.png) [@josklaps1](https://community.wolfram.com/u/josklaps1)\
**Post date:** [April 11, 2017, 1:04pm UTC](https://community.wolfram.com/t/plot-a-left-and-a-right-axis-with-listplot/10295/10 "2017-04-11T13:04:47Z")

</div>

@Hendrik, I know this code but is much more complicated as you aleready mentioned. The function “Overlay” is simple to use.  
Thanks anyway for the tip and reply !

Regards,…Jos
