I have a simple graph using boxplot and I'm trying to customize the look. I'm part way there, but am having trouble with the average.
where I have changed the color of the box and the median, but the average is kind of lost. I changed the box using:
\pgfplotsset{
boxplot/draw/box/.code={%
\draw[/pgfplots/boxplot/every box/.try,color=.!50!white]
(boxplot box cs:\pgfplotsboxplotvalue{lower quartile},0)
rectangle
(boxplot box cs:\pgfplotsboxplotvalue{upper quartile},1)
;
},%
}
as per the manual (with the addition of the ",color=.!50!white") and the median similarly, but when I try the same thing with average,
\makeatletter
\pgfplotsset{
boxplot/draw/average/.code={%
\draw[/pgfplots/boxplot/every average/.try,fill=red]
\pgfextra
\pgftransformshift{%
\pgfplotsboxplotpointabbox
{\pgfplotsboxplotvalue{average}}
{0.5}%
}%
\pgfuseplotmark{\tikz@plot@mark}%
\endpgfextra
;
},
}
\makeatother
nothing changes. I tried many other things, including adding:
\addplot+[boxplot prepared={ % IE11 dotget
draw position=1,
every average/.style={fill=red,mark={diamond*}},
average=100.2, lower whisker=98.1, lower quartile=98.4, median=100.5, upper quartile=101.2, upper whisker=101.5}]
coordinates { };
but still no joy.
Thanks for any help! ../Dave
Best Answer
Simply add a
\color
command before the\draw
command to achieve your desired result.(Have a look at the code below which gives an example by using code from the PGFPlots manual and adding the color line.)