import matplotlib.pyplot as plt
x_point = [2,-2]
y_point = [2,-2]
plt.scatter(x_point,y_point)
plt.xlim(-10,10) #x坐标轴范围-10~10
plt.ylim(-10,10)
#第一个参数为标记文本,第二个参数为标记对象的坐标,第三个参数为标记位置
plt.annotate('(2,2)', xy=(2,2), xytext=(2.5,2.5))
plt.annotate('(-2,-2)', xy=(-2,-2), xytext=(-1.5,-1.5))
plt.grid()#网格线显示
plt.show()
Python matplotlib画坐标点并且以文本内容标记
最新推荐文章于 2023-06-16 12:27:01 发布