I would like to know whether and how the pgfplots package can be used to produce a plot with two curves using different scales, like in the following example: enter image description here

1 Answer 1


See section 4.8.10 – "Two Ordinates (y axis) or Multiple Axes" – in the pgfplots manual. The following is ripped from the first example (with preamble added):





    scale only axis,
    axis y line*=left,% the ’*’ avoids arrow heads
    ylabel=First ordinate]
  \addplot {x^2};
    scale only axis,
    axis y line*=right,
    axis x line=none,
    ylabel=Second ordinate]
    \addplot[red] {3*x};

  • Thanks for the answer. -- For anyone else searching for that manual section: in the current version (pgfglots 1.14) it moved to section 4.9.11.
    – mschuett
    Oct 5, 2016 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .