Plot a Point or a Line on an Image with Matplotlib
Matplotlib and its constituents support a lot of functionality. One such functionality is that we can draw a line or a point on an image using Matplotlib in python.
- Import modules
- Read the image
- Plot the line or point on the image
- Display the plot/image.
Implementation using the above approach on the given image is provided below:
Example 1 : Drawing a point on the image.
Attribute used: marker
It is used to define what marker type should the point be displayed in.
Example 2 : Draw a line on the image
To draw a line we will give the co-ordinates of two points in the plot function.
Attribute used: linewidth
Used to specify the width of the line.
Example 3 : Draw two intersecting lines crossing each other to make X.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course