9

when I am drawing a xbar chart, I have troubles with the legend entries. They appear to have the opposite ordering as I suppose they should have.

\begin{tikzpicture}
\begin{axis}[xbar]
  \addplot  coordinates {(2.659244418,1)};
  \addlegendentry{A}
  \addplot  coordinates {(18.95781994,1)};
  \addlegendentry{B}
\end{axis}
\end{tikzpicture}

Example plot

Either the bar position should switch or the legend label position. Somethings seems to be wrong here.

Maybe anyone has an idea?

14

You can reverse the order of the legend entries by setting reverse legend:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[xbar, reverse legend]
  \addplot  coordinates {(2.659244418,1)};
  \addlegendentry{A}
  \addplot  coordinates {(18.95781994,1)};
  \addlegendentry{B}
\end{axis}
\end{tikzpicture}

\end{document}
| improve this answer | |

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.