1

Issue

  • I use x dir = reverse to reverse the direction of the x-axis (arrow points to the left).
  • Is there an easy way to also move the x label to the "correct" position (mirrored regarding the y-axis compared to the "normal" case)?

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

% http://pgfplots.sourceforge.net/gallery.html
\begin{tikzpicture}
    \begin{axis}[
        axis lines = middle,
        xlabel = {x label},
        ylabel = {y label},
        x dir = reverse, % <-- Important
    ]
    % use TeX as calculator:
    \addplot {x^2 - x +4};
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Related

Positioning of Pgfplot axis labels

2

You can set the position with xlabel style={at={}}. The left of the plot is current axis.left of origin.

MWE:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

% http://pgfplots.sourceforge.net/gallery.html
\begin{tikzpicture}
    \begin{axis}[
        axis lines = middle,
        xlabel = {x label},
        xlabel style={at={(current axis.left of origin)},anchor=south west},
        ylabel = {y label},
        x dir = reverse, % <-- Important
    ]
    % use TeX as calculator:
    \addplot {x^2 - x +4};
    \end{axis}
\end{tikzpicture}

\end{document}

Result:

enter image description here

Source: PGFPLOTS manual section 4.9.9 Axis Lines.

4
  • Thanks a lot! And especially thanks for mentioning the source. – Dr. Manuel Kuehner Feb 7 at 19:27
  • Sorry for the late reply, I am in a difficult time zone. – Dr. Manuel Kuehner Feb 7 at 19:28
  • *"difficult" should be "different" :) – Dr. Manuel Kuehner Feb 8 at 3:37
  • 1
    @Dr.ManuelKuehner I was wondering indeed what a difficult time zone could be :) – Marijn Feb 8 at 7:32

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.