- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do you directly overlay a scatter plot on top of a jpg image in Matplotlib?
To directly overlay a scatter plot on top of a jpg image, we can take the following steps −
Load an image "bird.jpg", using imread() method, Read an image from a file into an array.
Now display data as an image.
To plot scatter points on the image make lists for x_points and y_points.
Generate random numbers for x and y and append in lists.
Using scatter method, plot x and y points.
To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = plt.imread("logo2.jpg") im = plt.imshow(data) x_points =  y_points =  for i in range(10): x_points.append(np.random.randint(0, 700)) y_points.append(np.random.randint(0, 700)) plt.scatter(x_points, y_points, c=x_points) plt.show()
- How to plot additional points on the top of a scatter plot in Matplotlib?
- How to animate a scatter plot in Matplotlib?
- How to show tick labels on top of a matplotlib plot?
- Plot scatter points on polar axis in Matplotlib
- How do you improve Matplotlib image quality?
- How do you create a legend for a contour plot in Matplotlib?
- How do you plot a vertical line on a time series plot in Pandas?
- Connecting two points on a 3D scatter plot in Python and Matplotlib
- How to insert a small image on the corner of a plot with Matplotlib?
- Plot scatter points on 3d plot without axes and grids in Matplotlib
- Plot scatter points on a 3D projection with varying marker size in Matplotlib
- How to make a discrete colorbar for a scatter plot in matplotlib?
- How to plot a watermark image in Matplotlib?
- How to overplot a line on a scatter plot in Python?
- Plot scatter points using plot method in Matplotlib