I want to show the (x,y) axis of points from a 2d array in a plot.
I know that by the following codes I can draw the points
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
plt.axis([0, 6, 0, 20])
plt.show()
Which show me this picture: output of the above code
However, I want to show the x,y of each point near to them in the plot. Something like this Which I am looking
Thank you very much in advance.
Dot Size. You can try to decrease marker size in your plot. This way they won't overlap and the patterns will be clearer.
Set the figure size and adjust the padding between and around the subplots. Initialize a variable overlapping to set the alpha value of the line. Plot line1 and line2 with red and green colors, respectively, with the same alpha value. To display the figure, use show() method.
This should do the trick:
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [1,4,9,16]
plt.plot(x, y, 'ro')
plt.axis([0, 6, 0, 20])
for i_x, i_y in zip(x, y):
plt.text(i_x, i_y, '({}, {})'.format(i_x, i_y))
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With