Reputation: 81
I have a small code producing the following picture with this code:
Code 1:
hist, rhist = np.histogram(r, bins=40, range=(0, 0.25))
hist = -hist/np.trapz(rhist[:-1],hist)
plt.plot(rhist[:-1], hist)
Output of code 1:
Then I try setting the plot to have a logarithmic Y axis so that I can recognise small peaks more clearly. This is the result.
Code 2:
hist, rhist = np.histogram(r, bins=40, range=(0, 0.25))
hist = -hist/np.trapz(rhist[:-1],hist)
plt.semilogy(rhist[:-1], hist)
Output of code 2:
As you can see, part of my plot disappears. There are 40 bins, I can however only count about 15 in the new plot. Any help will be greatly appreciated. I am using Enthought Canopy of the latest version for academic use. E.
UPDATE: I did find a similar question here, old, dead and unanswered though.
Upvotes: 2
Views: 1255
Reputation: 1797
Issue plt.yscale('symlog')
at the end of your plotting. See here for a description of 'symlog'
.
Upvotes: 1
Reputation: 8124
A common visual trick to "display" zero in log scale is to use a very small value instead:
plt.semilogy(rhist[:-1], hist+1e-6)
In this case beaware of correct interpretation of plot though.
Upvotes: 0
Reputation: 10650
I'm pretty sure it's just not plotting those values because they are zero.
Log(0) = -Infinity.
Plotting that is going to make your graph look pretty rubbish...
Upvotes: 1