Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

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):

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{width=7cm,compat=1.3}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
    scale only axis,
    xmin=-5,xmax=5,
    axis y line*=left,% the ’*’ avoids arrow heads
    xlabel=$x$,
    ylabel=First ordinate]
  \addplot {x^2};
  \end{axis}
  \begin{axis}[
    scale only axis,
    xmin=-5,xmax=5,
    axis y line*=right,
    axis x line=none,
    ylabel=Second ordinate]
    \addplot[red] {3*x};
  \end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.