6

I was looking for a way to fill the bars in bar plots or stacked bar plots with hashes or dots (something like the following figure).

enter image description here

Since it took me a long time to figure it out how to do it, I share my finding here as an answer, maybe it is useful for someone else.

2
  • 1
    Nice. You can answer your own question.
    – percusse
    Apr 22, 2013 at 0:00
  • Do you mean I should remove the second part from question, and it as answer?
    – antmw1361
    Apr 22, 2013 at 0:05

1 Answer 1

7

The key to solving the problem is using the pattern package which is introduced in the PGF manual.

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar stacked]
\addplot [draw=blue,pattern=horizontal lines light blue] coordinates {(1,1)  (2,3) (3,2)};
\addplot [draw=red, pattern color = green, pattern = north west lines] coordinates {(1,1)  (2,1) (3,1)};
\addplot [pattern = dots] coordinates {(1,1)  (2,1) (3,1)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .