- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- 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()
- Related Articles
- How to plot additional points on the top of a scatter plot in Matplotlib?
- How to animate a scatter plot in Matplotlib?
- Plot scatter points on polar axis in Matplotlib
- How to show tick labels on top of a matplotlib plot?
- Connecting two points on a 3D scatter plot in Python and Matplotlib
- How do you create a legend for a contour plot in Matplotlib?
- Plot scatter points on 3d plot without axes and grids in Matplotlib
- How to make a discrete colorbar for a scatter plot in matplotlib?
- How to annotate the points on a scatter plot with automatically placed arrows in Matplotlib?
- Plot scatter points on a 3D projection with varying marker size in Matplotlib
- Plot scatter points using plot method in Matplotlib
- How do you improve Matplotlib image quality?
- How do you plot a vertical line on a time series plot in Pandas?
- How to insert a small image on the corner of a plot with Matplotlib?
- Controlling the alpha value on a 3D scatter plot using Python and Matplotlib