# Reversing direction of x axis in pgfplots

I want to reverse to direction of the x axis in one of my plots. pgfplots offers the x dir=reverse key for this. However, this does not work as expected - not even in this example:

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=1,x=15cm,
ymin=0,ymax=1,y=10cm,
x dir=reverse]
\end{axis}
\end{tikzpicture}
\end{document}


In the compiled pdf, the plot starts with (0,0) at the left side, just like it would without the x dir=reverse option.

I have pgfplots 1.5 installed.

What's wrong here?

-
The problem is the x=15cm. – qubyte Feb 2 '12 at 9:50
UPDATE: this is (was) actually a bug in pgfplots. Starting with pgfplots 1.6, the example works flawlessly. – Christian Feuersänger Mar 27 '13 at 19:37

The problem is with how you're trying to set the width of the plot. Try this instead:

\documentclass{standalone}
\usepackage{pgfplots}
%
\pgfplotsset{compat=1.5, width=15cm, height=10cm, scale only axis}
%
\begin{document}
%
\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=1,
ymin=0,
ymax=1,
x dir=reverse
]
\end{axis}
\end{tikzpicture}
%
\end{document}


Your plots axes will all be the same size unless otherwise specified.

-
Ah, that's it! Thanks you! – Christoph Feb 2 '12 at 10:02
You're welcome! – qubyte Feb 2 '12 at 10:16

It is due to your placement of x=15cm. What reverse does is simply x=-x. So in your case you can do:

\begin{axis}[xmin=0,xmax=1,x=-15cm,
ymin=0,ymax=1,y=10cm]

However, x= has precedence over x dir which is why you get the setting you have.