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:

\caption{Comparison of Solutions}
  \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}

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:


1 Answer 1


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


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.