2

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: enter image description here

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: enter image description here

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.

4

3 回答 3

1

在您的绘图结束时发布plt.yscale('symlog')。有关. _ _'symlog'

于 2013-07-16T19:42:15.723 回答
1

我很确定它只是没有绘制这些值,因为它们为零。

Log(0) = -无穷大。

绘图会让你的图表看起来很垃圾......

于 2013-07-15T23:50:58.450 回答
0

在对数刻度中“显示”零的一个常见视觉技巧是使用一个非常小的值来代替:

plt.semilogy(rhist[:-1], hist+1e-6)

在这种情况下,请注意对情节的正确解释。

于 2013-07-15T23:58:19.730 回答