9

I have a question concerning the appearance of the multiplier above axis if scaled ticks = true is used.

I like to have two curves in one plot. The example shows my problem. I like to have scaled ticks above right axis but it appears above the left axis. Does anybody know how to fix it?

When I created this small example a second question occurs. Try to write axis y line*=right instead of axis y line=right. The label "y pos-right" moves to the left side an top of the "y pos-left". Any explanations for that and how to fix it?

\documentclass[a4paper,10pt]{scrreprt}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
axis y line*=left,
ylabel = y pos-left
]

\addplot[red] coordinates
{(-3,0) (-2,0.1) (-1,-0.6)
(0,1)
(1,-0.6) (2,0.1) (3,0)};

\end{axis}

\begin{axis}[
axis y line=right,
scaled ticks = true,
xlabel = x pos-right,
ylabel = y pos
]

\addplot[blue] coordinates {(-3,-12000) (-2,11000)
(-1,-6000) (0,1000) (1,-100) (2,50) (3,0)};

\end{axis}
\end{tikzpicture}

\end{document}

Thanks in advance

7

By default, the scale label position is hard-coded to the upper left corner of the plot. If you set the option ylabel near ticks, however, this is corrected. It also fixes the incorrect placement of the y label when using axis y line*=right.

\documentclass[a4paper,10pt]{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
axis y line*=left,
ylabel = y pos-left
]

\addplot[red] coordinates
{(-3,0) (-2,0.1) (-1,-0.6)
(0,1)
(1,-0.6) (2,0.1) (3,0)};

\end{axis}

\begin{axis}[
axis y line*=right,
scaled  ticks = true,
ylabel near ticks,
xlabel = x pos-right,
ylabel = y pos
]

\addplot[blue] coordinates {(-3,-12000) (-2,11000)
(-1,-6000) (0,1000) (1,-100) (2,50) (3,0)};

\end{axis}
\end{tikzpicture}

\end{document}
  • 1
    It is advisable to write \pgfplotsset{compat=1.5} in your preamble - which also solves the problem: any value with version greater or equal to compat=1.3 automatically activates ylabel near ticks for all figures in the plot. – Christian Feuersänger Apr 23 '12 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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