# Thickness of bars in a histogram

How can I control the thickness of the bars (here vertical lines) in a Histogram plot? For example in the plot below (of the corresponding image: http://goo.gl/RyMpXE) I can hardly see histogram bars above 300 brightness.

Code for producing the histogram:

imageData = Flatten[ImageData[image, "Bit16"]];

Histogram[imageData, {0, 2500, 1}, Frame -> True,
ScalingFunctions -> "Log", PlotRange -> {{0, 2500}, {All, 10^6}},
ImageSize -> 2000,
BaseStyle -> {FontWeight -> "Bold", FontSize -> 40,
FontFamily -> "Calibri"},
FrameLabel -> {{"# of Pixels", ""}, {"Brightness", ""}}];


I would like to use in my case a bin width of 1. Since one brightness value occurs above 2000 I want to be able to see the corresponding bar - which is too thin.

• Wouldn't the thickness of the bars be imposed by the binning you are using? I think you might have to use wider bins to get wider bars. Or perhaps use higher-contrast colors, or a non-white background. Can you show us the code that generated your graph? – MarcoB Jan 29 '16 at 17:49
• Adding Background -> Black makes for a more visible line (picture), although of course it does not change the width of the bin. – MarcoB Jan 29 '16 at 18:14

Histogram generates Rectangle objects as bars whose edges are set to be transparent. In your case the rectangles are so thin that you can thicken them simply by drawing their edges. This will apply to all bins though!

yourhistogram = Histogram[imageData, {0, 2500, 1}, Frame -> True,
ScalingFunctions -> "Log",
(* Note the modified plot range! the original one clipped the highest bars for me *)
PlotRange -> {{0, 2500}, All},
ImageSize -> 2000,
BaseStyle -> {FontWeight -> "Bold", FontSize -> 40, FontFamily -> "Calibri"},
FrameLabel -> {{"# of Pixels", ""}, {"Brightness", ""}}];

yourhistogram /.
EdgeForm[Directive[Opacity[0.]]] -> EdgeForm[{Orange, Opacity[1], Thickness[0.003]}]


• @mrz You are very welcome! Thank you for the accept as well. – MarcoB Jan 29 '16 at 22:33

You can use Histogram[{x1,x2,x3...},bspec], where bspec is bin width specification.

Simple example:

data = RandomVariate[NormalDistribution[0, 1], 200];
Histogram[data, 5]


Output:

Alternatively, you could changethe presentation to see the bins better:

Simple example:

data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1/2], 500];
data3 = RandomVariate[NormalDistribution[5, 1/3], 500];

Histogram[{data1, data2, data3}, ChartStyle -> {Red, Green, Blue}]


Output:

Or using PlotTheme

Simple Example:

data = RandomVariate[NormalDistribution[0, 1], 200];
Histogram[data, 5 , PlotTheme -> "Marketing"]


Output:

Reference:

Histogram

• I know that - my question is different ... see added information in bold above ... – mrz Jan 29 '16 at 18:14
• @mrz the width of the bin to which you referred to as thickness is governed by the bin specification. If you insist on keeping it at 1, the only ways known to me how to make the bins more visible are specified above. I do apologise if it didn't meet your requirements. – e.doroskevic Jan 29 '16 at 18:45
• Thank you for your help ... may be I was a little bit unclear. Sometimes an answer which does not exactly solves my question helps for an other problem. So I am always happy for each response. – mrz Jan 29 '16 at 21:42