# How to specify custom “ColorScheme” for “GradientScaleBoxWhisker” ChartElementFunction and Whiskers & Fences of BoxWhiskerChart?

With BoxWhiskerChart you can specify a gradient scale fill for the boxes using the ChartElementFunctionand the "GradientScaleBoxWhisker" ChartElementDataFunction.

SeedRandom[456];
data = RandomVariate[LogNormalDistribution[#, .04], 20] & /@ {.1, .16};

BoxWhiskerChart[data, "Outliers",
"ColorScheme" -> "RoseColors"]]


The gradient fills over the range of the chart. I would like it to fill over the first to third quartile range of each data series; Red at first quartile, Orange at second quartile, and Green at third quartile.

sc = Function[{x}, Blend[{{#1, Red}, {#2, Orange}, {#3, Green}}, x]] &[
Sequence @@ #] & /@ (Quantile[#, {0.25, .5, 0.75}] & /@ data)
(*
{Function[{x}, Blend[{{1.04715, Red}, {1.07836, Orange}, {1.14039, Green}}, x]],
Function[{x}, Blend[{{1.16097, Red}, {1.18109, Orange}, {1.19066, Green}}, x]]}
*)


Using sc in place of "RoseColors" errors out.

BoxWhiskerChart[data, "Outliers",
"ColorScheme" -> sc]]


I think I would also need some form of ColorFunctionScaling -> False as well. However, this option is not valid for either BoxWhiskerChart nor ChartElementDataFunction.

I would also like to color the top whisker and fence Green and the bottom Red. The element styling only appears to allow one style for both.

Is there a way to get the gradient fill and whisker/fence styling I want by using BoxWhiskerChart? I would prefer to use BoxWhiskerChart instead of drawing it all with Graphics so I have the options of all the element and outlier features of this function.

• Maybe you need to compact your title:) – xyz Jul 11 '16 at 3:31

Using your sc to define a list of colors as the value for the "ColorScheme" option in a custom ChartElementFunction:

ClearAll[ceF];
ceF[cu_: Green, cl_: Red] := Module[{cs = Module[{qt = Quartiles@#2},
(Function[{x}, Blend[{{#1, Red}, {#2, Orange}, {#3, Green}}, x]] & @@ qt) /@
Subdivide[qt[[1]], qt[[-1]], 20]]},

BoxWhiskerChart[data, "Outliers", ChartElementFunction ->