I wish to know how to insert a dot (or some kind of marker) at a distinct point on a curve/line in matplotlib. Using the tutorial documentation, http://matplotlib.org/users/pyplot_tutorial.html
we plot
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16])
plt.axis([0, 6, 0, 20])
plt.show()
Now, I know how to transform this line into a series of points, here using red dots 'ro'
:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
plt.axis([0, 6, 0, 20])
plt.show()
How can I add a "dot" at a distinct point? For example, add a dot at point [3,9]
?
Plot the data and data points using plot() method. Set X and Y axes scale. To put a circled marker, use the plot() method with marker='o' and some properties. Annotate that circle (Step 7) with arrow style.
You can call plt.plot(x, y, 'style')
again, like:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro') # Your original list
plt.plot(5, 25, 'go') # Additional point
plt.plot(6, 36, 'yo') # Additional point
plt.axis([0, 10, 0, 40]) # Modified axis
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