ColorFunction in Histogram[]
You can use a custom ChartElementDataFunction
as follows:
cedF[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] :={If[xmax <= 8,
RGBColor[1, 0, 0], Sequence[]],
Dynamic@EdgeForm[Directive[Thickness[.015], Lighter@CurrentValue["Color"]]],
Rectangle[{xmin, ymin}, {xmax, ymax}, RoundingRadius -> 5]};
Histogram[RandomVariate[NormalDistribution[10, 2], 500],ChartStyle -> "Pastel",
ChartElementFunction -> cedF]
EDIT: Adding arguments to cedf
:
cedf2[from_,to_,color_: Red, t_:Small, rr_: 0][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] :=
{If[from < xmax <= to, color, Sequence[]],
Dynamic@EdgeForm[Directive[Thickness[t], Lighter@CurrentValue["Color"]]],
Rectangle[{xmin, ymin}, {xmax, ymax}, RoundingRadius -> rr]}
Histogram[RandomVariate[NormalDistribution[10, 2], 500], ChartStyle -> "Pastel",
ChartElementFunction -> cedf2[6, 10, Purple, Small, 3]]
Alternatively, you can build a custom data function using the built-in ChartElementDataFunctions
:
sgmntsclF = ChartElementDataFunction["SegmentScaleRectangle",
"Segments" -> 8, "ColorScheme" -> "TemperatureMap"];
grdntrctF = ChartElementDataFunction["GradientRectangle",
"ColorScheme" -> "Rainbow", "GradientOrigin" -> Top];
Histogram[RandomVariate[NormalDistribution[10, 2], 500], ChartStyle -> "Pastel",
ChartElementFunction -> ((If[7 < #[[1, 2]] <= 10, sgmntsclF[##], grdntrctF[##]]) &)]
You will probably need to get the bin data with HistogramList and plot it with BarChart.
I don't have HistogramList in v7, but here is a basic proof of concept:
hist = Histogram[RandomReal[NormalDistribution[10, 2], 500]]
Cases[hist, RectangleBox[{a_, _}, {b_, x_}] :> {b, x}, -1];
If[# <= 8, Style[#2, Red], #2] & @@@ %;
BarChart @ %
I'm flying blind here as I can't test this, but maybe it works:
dat = HistogramList[RandomVariate[NormalDistribution[10, 2], 500]];
If[# <= 8, Style[#2, Red], #2] & @@@ Transpose @ dat;
BarChart @ %