Menu

#100 Interchanged x and y coordinates in the legend images of horizontal bars

v1.0 (example)
closed-fixed
nobody
None
5
2015-12-28
2015-12-26
No

There is a problem with the xbar legend image, see http://tex.stackexchange.com/q/284688/43317. May be the x and y coordinates in the legend image code of the xbar legend are interchanged?

\documentclass{article}
\usepackage{pgfplots}
%\pgfplotsset{
  %/pgfplots/xbar legend/.style={
    %/pgfplots/legend image code/.code={%
      %\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt]
      %plot coordinates {(0.8em,0cm)(0.6em,2*\pgfplotbarwidth)};}% <- changed
%}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xbar]
\addplot coordinates { (5.1,1)(2.5,2)};
\legend{legend1}
\end{axis}
\end{tikzpicture}
\end{document}

Discussion

  • Christian Feuersänger

    Thanks for the bug report! You are right, this is a bug.

    The suggested solution resembles the very same solution that I added two weeks ago. It will become part of the next stable of pgfplots (will come before the end of January 2016).

     
  • Christian Feuersänger

    • status: open --> closed-fixed