擅长:python、mysql、java
<p>问题是<a href="http://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.axvline.html#matplotlib.axes.Axes.axvline" rel="nofollow noreferrer">^{<cd1>}</a>接受<code>ymax</code>范围0到1的值(即,它在轴坐标系中,而不是在数据坐标系中)。从文件中:</p>
<blockquote>
<p><code>ymax</code> : scalar, optional, default: 1</p>
<p>Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.</p>
</blockquote>
<p>所以,你告诉它只在轴上0.1处绘制。如果您希望继续使用<code>axvline</code>来绘制,则需要在绘制之前缩放这些值。在</p>
<p>例如</p>
<pre><code>fig=plt.figure(figsize=(10,10))
binom=[scs.binom.pmf(k,100,0.2) for k in range(100)]
print(np.max(binom)) #0.0993002148088
# Set ymax here
ymax = 0.1
# Scale the yvalues by ymax
[plt.axvline(k,ymax=scs.binom.pmf(k,100,0.2)/ymax) for k in range(100)]
# Use ymax again here
plt.ylim(ymax=ymax)
plt.show()
</code></pre>
<p>或者,您可以考虑使用<code>plt.bar</code>来绘制此图;例如:</p>
^{pr2}$