Let's say I have two samples:
data1 = RandomChoice[DateRange[{2010, 1, 1}, {2010, 4, 31}, "Day"], 100];
data2 = RandomChoice[DateRange[{2010, 5, 1}, {2010, 8, 31}, "Day"], 100];
I want to plot a histogram with both of them, and I want data2's
bars to have Dotted
or Dashed
EdgeForm
depending of a value of some variable, let's say t
.
Problems with available styling options:
Dynamic @ DateHistogram[...]
, recreating it will be too slow for bigger samples.ChartStyle
can't beDynamic
or contain it in a list. It can haveDirectives
but they can't containDynamic
either so it won't work as a wrapper.ChartElementFunction
does not allow to distinguish data samples.Histogram*
allows certain wrappers for data, e.g.Style
:Style[data2, Orange]
but it won't allowDynamic
inside
The only way I was able to use is a hairy postprocessing:
t = True; Checkbox @ Dynamic @ t
DateHistogram[
{data1, data2}, ChartStyle -> {Green, Red}
] /. d_Directive :> Which[
MemberQ[d, Red, ∞],
Dynamic[
Directive[##, EdgeForm[If[TrueQ[t], Dashed, Dotted]]]
] & @@ d
,
True,
d
]
Is there a more stable/generic way to achieve this?
Directive
s complicate post-processing too much. WhyDirective
isn'tFlat
?! I see no reason to keep nested structures ofDirective
s. $\endgroup$DateHistogram
(which I don't have) necessary for this example or could you be using aHistogram
instead? $\endgroup$Histogram
I can useHistogramList
to assembleGraphics
by myself and have a full control. But forDateHistogram
it is not possible :/ HistogramList for DateHistogram? $\endgroup$