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

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

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}
share|improve this answer
    
Works well, Thanks –  johann Apr 23 '12 at 18:12
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
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.