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 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]
      \addplot coordinates{(0,0) (1,1)};
    \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?

share|improve this question
    
The problem is the x=15cm. –  qubyte Feb 2 '12 at 9:50
1  
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
add comment

2 Answers

up vote 6 down vote accepted

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
    ]
      \addplot coordinates{(0,0) (1,1)};
    \end{axis}
  \end{tikzpicture}
%
\end{document}

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

share|improve this answer
1  
Ah, that's it! Thanks you! –  Christoph Feb 2 '12 at 10:02
    
You're welcome! –  qubyte Feb 2 '12 at 10:16
add comment

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]
  \addplot coordinates{(0,0) (1,1)};
\end{axis}

It is the equivalent of reversing the axis.

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

share|improve this answer
    
I feel dumb now. –  Christoph Feb 2 '12 at 9:48
1  
Don't, it isn't obvious unless you know it. :) –  zeroth Feb 2 '12 at 9:49
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.