显示各点横纵坐标:
from matplotlib import pyplot as plt
x = [1, 2, 3, 4, 5, 6]
y = [10, 20, 30, 40, 50, 60]
plt.plot(x, y, 'r*')
# 添加一个for循环,显示各点横纵坐标 (x, y)
for a, b in zip(x, y):
plt.text(a, b, (a, b))
plt.show()
运行结果为:

from matplotlib import pyplot as plt
x = [1, 2, 3, 4, 5, 6]
y = [10, 20, 30, 40, 50, 60]
plt.plot(x, y, 'r*')
# 添加一个for循环,显示各点横纵坐标 (x, y)
for a, b in zip(x, y):
plt.text(a, b, (a, b))
plt.show()
运行结果为: