擅长:python、mysql、java
<p>您需要在for循环中调用<code>pylab.text()</code>:</p>
<pre><code>import pylab as pl
xs = [0, 1, 2]
ys = [2.5, 4, 3]
pl.plot(xs, ys, "-o")
for x, y in zip(xs, ys):
pl.text(x, y, str(x), color="red", fontsize=12)
pl.margins(0.1)
</code></pre>
<p><img src="https://i.stack.imgur.com/Fftqp.png" alt="enter image description here"/></p>