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.

In the legend for a bar plot that I'm building, I'm only getting a small tick next to the name, not a block of color. I'm not defining any special cycle lists. The code for the plot is:

\begin{figure}
\caption{Comparison of Solutions}
\begin{tikzpicture}
  \begin{axis}[xbar interval=0.7, height=400pt, width=3.25in, symbolic y coords={a,b,c,d,e}, ylabel={Number of Nodes}, xlabel={Number of Colors}, yticklabels={50,100,200,500,100}, legend style={cells={anchor=south west, inner xsep=0, inner ysep=0, fill}, nodes={inner sep=0}}]
  \addplot table [x=colors, y=symb]{\colorseight};
  \addplot table [x=colors, y=symb]{\colorssixteen};
  \addplot table [x=colors, y=symb]{\colorsthirtytwo};
  \addplot table [x=colors, y=symb]{\dfseight};
  \addplot table [x=colors, y=symb]{\dfssixteen};
  \addplot table [x=colors, y=symb]{\dfsthirtytwo};
  \addplot table [x=colors, y=symb]{\comeight};
  \addplot table [x=colors, y=symb]{\comsixteen};
  \addplot table [x=colors, y=symb]{\comthirtytwo};
  \legend{DiMa2eD (4 links), DiMa2ed (8 links), DiMa2ed (16 links),4,5,6,7,8,9,10,11,12}
  \end{axis}
\end{tikzpicture}
\label{plo:colors}
\end{figure}

Each macro refers to a different tab deliniated file. Here is one that can be duplicated for experimenting.

nodes   colors  links   symb
50  178     16  a
100     176     16  b
200     177     16  c
500     183     16  d
500     183     16  e

and the preamble command to create the macro:

\pgfplotstableread{data/dfs.tab}\bestdfs
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Adding the option area legend to the axis options draws a little rectangle in the legend instead of a line segment (p. 120 in the pgfplots manual).

With the axis options legend style={cells={anchor=center, fill}, nodes={inner sep=1,below=-1.1ex}},area legend and your example file I get

Bar plot legend in pgfplots

share|improve this answer
    
Can't think how I missed that, thanks! –  philosodad Feb 5 '11 at 2:43
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.