Reputation: 43
I have a problem displaying histograms in matplotlib when both options histtype='stepfilled' and log=True are used. I had this problem in matplotlib version 1.1.0 and found that this is still present in version 1.2.0.
Unfortunately I don't have the rights to post images, but you can check out this behaviour with this simple code:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mu, sigma = 200, 25
x = mu + sigma*np.random.randn(10000)
n, bins, patches = plt.hist(x, 50, normed=1, histtype='bar',log=True)
plt.savefig("test1.png")
plt.clf()
n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled',log=True)
plt.savefig("test2.png")
The first figure shows correctly, whereas in the second case, with the option histtype='stepfilled' instead of 'bar', no. Somebody has any clue?
Upvotes: 4
Views: 5786
Reputation: 1272
If you use
plt.hist(x, 50, normed=1, histtype='stepfilled')
plt.semilogy()
you get the expected result, with the caveat that it looks weird for bins with zero values.
Upvotes: 1
Reputation: 8264
It's an open bug in matplotlib. Maybe you can simulate the stepfilled
manipulating the style of the bars in the first graphic.
The issue on github:
Upvotes: 1