3

In PGFPlots I would like to have the multiplier for the specific axis near this axis when the axis is in the middle. The option xlabel near ticks does that, but moves the axis-label to the center of the plot.

I would prefer to have the multiplier and the axis label at the right end of the axis. I couldn't find a solution in the pgfplots manual.

Example:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[%
                    width=0.8\textwidth,%
                    legend style={%
                    at={(0,0.5)},
                    anchor=south west },%
                    title={\bfseries Plot},%
                    axis x line=middle,%
                    axis y line=middle,%
                    minor tick num=9,%
                    xlabel=X-Axis,%
                    ylabel=Y-Axis ,%
                    scaled x ticks=base 10:3,%
                    %xlabel near ticks,%
                ]

                \addplot [domain=-0.03:0.03, mark=none, thick,blue,] 
                {10000*x + 50};

                \legend{Line}

    \end{axis}
\end{tikzpicture}
\end{document}
  • 2
    I just asked a little to early. If you set \pgfplotsset{compat=1.9} the problem is solved. Stupid me. – olsch88 Feb 20 '14 at 15:28
5

As you have already noticed, using compat=1.9 moves the multiplier automatically. However, you can use the every x tick scale label style, in case finer control is needed (or an older version of pgfplots` is installed):

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{every x tick scale label/.style={
  at={(axis description cs:1,0.5)},yshift=-4em,inner sep=0pt,left
 }
}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[%
                    width=0.8\textwidth,%
                    legend style={%
                    at={(0,0.5)},
                    anchor=south west },%
                    title={\bfseries Plot},%
                    axis x line=middle,%
                    axis y line=middle,%
                    minor tick num=9,%
                    xlabel=X-Axis,%
                    ylabel=Y-Axis ,%
                    scaled x ticks=base 10:3,%
                    %xlabel near ticks,%
                ]

                \addplot [domain=-0.03:0.03, mark=none, thick,blue,] 
                {10000*x + 50};

                \legend{Line}

    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

The default definition for the style:

/pgfplots/every x tick scale label/.style={
  at={(1,0)},yshift=-2em,left,inner sep=0pt
}

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.