Hello,

the "Two Ordinates (y axis) or Multiple Axes" is very useful in
technological area but, for instance for my students who follows my
LaTeX and pgfplot course (who aren't fond of computer science), the
current way to achieve the result, for instance:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
% let both axes use the same layers
\pgfplotsset{set layers}
\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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

is a bit tricky. Moreover, create a unique legend in this kind of plot
is not that easy, see for instance:

http://tex.stackexchange.com/questions/42697/pgfplots-legends-in-multiple-y-axis-plot-overlapping

So it could be nice for pgfplots to provide higher level commands, for
instance something like:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
\begin{doubleaxis}[
  xlabel=$x$,
  yleftlabel=First ordinate,
  yrightlabel=Second ordinate
]
\addplot {x^2};
\addplot {3*x};
\legend{$y=x^2$,$y=3x$}
\end{doubleaxis}
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

where:

  1. the:

      * \pgfplotsset{set layers}
      * scale only axis
      * xmin=..., xmax=...,
      * axis y line*=left
      * axis y line*=right
      * axis x line=none

    would be hidden in the doubleaxis definition,

  2. the first addplot would be the left one and the second, the right
  one,

  3. the comma separated list in the \legend command's argument applies
  successively to the two \addplot.

All the best.
-- 
Denis

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

Reply via email to