Matplotlib 如何标记顶点并将x和y值添加到坐标?
Matplotlib 如何标记顶点并将x和y值添加到坐标?,matplotlib,vertices,Matplotlib,Vertices,如果使用matplotlib绘制图形,如何标记顶点并将x和y值添加到坐标? 我的代码如下。多谢各位 import numpy as np import matplotlib.pyplot as plt def f(x):[![enter image description here][1]][1] return x ** 2 If __name__ == '__main__': x = np.arange(-2, 2, 0.1) y = f(x) plt.
如果使用matplotlib绘制图形,如何标记顶点并将x和y值添加到坐标? 我的代码如下。多谢各位
import numpy as np
import matplotlib.pyplot as plt
def f(x):[![enter image description here][1]][1]
return x ** 2
If __name__ == '__main__':
x = np.arange(-2, 2, 0.1)
y = f(x)
plt.plot(x, y, label='f(x)')
plt.legend()
plt.show()
你是说x和y标签吗 你可以做:
plt.xlabel('xlabel'))
plt.ylabel('ylabel')
要标记该特定点,可以尝试:
plt.annotate('label',xy=(x,y))
你是指x和y标签吗
你可以做:
plt.xlabel('xlabel'))
plt.ylabel('ylabel')
要标记该特定点,可以尝试:
plt.annotate('label',xy=(x,y))
可能会有所帮助。可能会有帮助。谢谢你的建议,这确实是我想要的功能。谢谢你的建议,这确实是我想要的功能。