I have a bar plot graph and I want to use patterns to fill the columns. However it seems that patterns are not working. For compiling I use pdflatex or lualatex.

I also wanted to use pattern width different fill color. Is that possible?




\pgfplotsset{every tick/.style={black,}}

    compat/show suggested version=false,
    tick label style={font=\footnotesize},
    label style={font=\footnotesize},
    legend style={%
        legend columns=2
        legend cell align=left,
        nodes={inner xsep=2pt,inner ysep=0.4pt,text depth=0.15em},

    symbolic x coords={AAA,BBB},
    bar width=16pt,
    enlarge x limits=0.4,
    nodes near coords,
    legend entries={C,D,E,G},

    \addplot[pattern=horizontal lines] coordinates {(AAA,0.32) (BBB,0.43)};
    \addplot[pattern=vertical lines] coordinates {(AAA,0.91) (BBB,0.93)};
    \addplot[pattern=north east lines] coordinates {(AAA,0.19) (BBB,0.16)};
    \addplot[pattern=north west lines] coordinates {(AAA,0.74) (BBB,0.72)};

enter image description here


For the pattern color use:

\addplot[red,pattern=horizontal lines, pattern color=red] coordinates {(AAA,0.32) (BBB,0.43)};

The first red is for the contour of the bar e the pattern color=red is for the pattern itself.

What errors do you have? I use pgfplots 1.5.1 so I use compat=1.5 and I comment your compat/show suggested version=false line and this works for me.

enter image description here

| improve this answer | |
  • 1
    It seems in the newer versions of PGFplots it only works when compiling with latex+dvips+ps2pdf or latex+dvipdf. – cacamailg May 31 '13 at 14:59

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.