1

Is it possible to combine a pattern with a background color in Pgfplot boxplot?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{statistics}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
ytick={1},
yticklabels={Index 0},
]
\addplot+[
boxplot prepared={ median=1, upper quartile=1.,  lower quartile=0.5, upper whisker=1.5, lower whisker=0. },
fill=green,
draw=red,
pattern=north east lines,
] coordinates {};

\end{axis}
\end{tikzpicture}

\end{document}

It seems that pattern and fill cannot be combined. Any Idea?

I also tried using postaction as mentioned in How to combine fill and pattern in a pgfplot bar plot?

\addplot+[boxplot prepared={  median=1,  upper quartile=1.,  lower quartile=0.5,   upper whisker=1.5,  lower whisker=0.},
 fill=green,
 draw=red,  
 postaction={pattern=north east lines}
 ] coordinates {};

The boxplot result is the following

enter image description here

  • 1
    Welcome to TeX-SE! Please have a look at https://tex.stackexchange.com/a/25032/121799. –  Mar 14 '19 at 16:13
  • @marmot ... Possibly my mistake, but trying to do it and it doesn't show the pattern but just the green fill. Can you please add it as an answer with the exact code? – koleygr Mar 14 '19 at 16:28
  • @marmot: Ok... got it... need the way with nomorepostaction of the accepted answer – koleygr Mar 14 '19 at 16:32
  • 1
    @koleygr Yes, that's true. –  Mar 14 '19 at 16:51

0 Answers0