1

I wonder why the bins are not showing a boundary between each other. It's confusing to look at it. I attached an example below:

Example histogram

for key,value in dict.items():
    plt.figure()
    plt.hist( value, bins='auto') 
    plt.title("Histogram for THR")
    plt.show()
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
Lora Sinha
  • 39
  • 1
  • 2
  • 7
  • That looks correct, perhaps you are thinking of a bar graph. In a histogram the x-axis represents a continuous variable, albeit grouped, and the y-axis, the count. In a bar graph, the x-axis are for nominal data and the spacing between the bars is to show that the groupings are not connected logically. – NaN Apr 17 '17 at 12:36
  • No I don't mean a bar graph. Check out the example here :https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html. I upgraded matplotlib and Numpy recently. I know it is the correct histograms, but I want the boundaries between the bins. I don't want them all looking like a big sold fused shape. – Lora Sinha Apr 17 '17 at 14:05
  • you had better edit your post and include you frequency and key values, since the help topic example works fine for me in your link, using numpy 1.11 and matplotlib 1.5.x. Are you using matplotlib 2.0 perhaps? – NaN Apr 17 '17 at 15:36

1 Answers1

1

That's the new default style for matplotlib 2.0 (for example, see the plots from the documentation for plt.hist in v2.0).

To force the edges of the bins to be displayed you can pass the edgecolor= (or ec=) argument to plt.hist, e.g. plt.hist(values, bins='auto', ec='k') for black bin edges.

ali_m
  • 71,714
  • 23
  • 223
  • 298