Removing a histogram's vertical edges

I think you could achieve what you want by overlaying two Histogram objects, one with no Edges but colored bars, the second one with Edges, but transparent bars, as in this example:

data = RandomVariate[NormalDistribution[10, 2], 500];
Show[{
    Histogram[data, ChartStyle -> Directive[Opacity[0], EdgeForm[AbsoluteThickness[4]]]],
    Histogram[data, ChartStyle -> EdgeForm[None]]
}]

Here is the result:

Overlaid histograms


The underlying problem is that Histogram creates a set of Rectangles which represent the bars. You can inspect this by looking at the underlying form of the created graphics

h = Histogram[RandomVariate[NormalDistribution[10, 2], 500], 
  Automatic, "PDF", PerformanceGoal -> "Speed"];
InputForm[h]

This reveals that each bar in the histogram is represented as

Rectangle[{5., 0}, {6., 3/125}, "RoundingRadius" -> 0]

Now the hard part becomes visible, because although you can set the EdgeForm of each Rectangle, you cannot easily make it so that the whole histogram has a surrounding edge. You can solve the issue by using some trickery as @MarcoB did in his answer. This is a perfectly fine solution.

Another way is to extract the points that define the given rectangles and use them to create one polygon which represents all bars. If you give this polygon a black edge, then it will show what you like. Then you draw this polygon over your existing Histogram:

adjust[gr_] := Show[
  gr,
  Graphics[{EdgeForm[{Black}], FaceForm[RGBColor[0.98, 0.81, 0.49]], 
    Polygon[Cases[gr, 
       Rectangle[{x1_, y1_}, {x2_, y2_}, _] :> 
        Sequence[{x1, y1}, {x1, y2}, {x2, y2}, {x2, y1}], 
       Infinity] //. {s___, a_, a_, e___} :> {s, e}]}]
  ]
adjust[h]

Mathematica graphics


You can also Plot the scaled PDF of the HistogramDistribution of data:

SeedRandom[1]
data = RandomVariate[NormalDistribution[10, 2], 500];
hd = HistogramDistribution[data];

{min, max, length} = Through@{Min, Max, Length}@data;
Plot[Evaluate[length PDF[hd, x]], {x, min - 2, max + 2}, 
 AxesOrigin -> {min - 2, 0}, Exclusions -> None, PlotStyle -> Thick, Filling -> Axis]

enter image description here

Tags:

Histograms