If I plot the graph with matplotlib, how do I mark the vertices and add the x and y values to the coordinates?
My code is as follows. Thank you.
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()
Do you mean x and y labels?
You can do:
plt.xlabel('xlabel')
plt.ylabel('ylabel')
To label that specific point, you can try:
plt.annotate('label', xy=(x, y) )