- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 to insert a small image on the corner of a plot with Matplotlib?
To insert a small image on the corner of a plot with matplotlib, we can take the following steps−
- Read an image from a file into an array using imread() method.
- Using subplots() method, create a figure and add a set of subplots.
- Plot a line on the current axis.
- Create newax (new axis) to show the image array (Step 1).
- Turn off the newly created axis, created for an image insert.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True im = plt.imread('bird.jpg') # insert local path of the image. fig, ax = plt.subplots() ax.plot(range(10)) newax = fig.add_axes([0.8,0.8,0.2,0.2], anchor='NE', zorder=1) newax.imshow(im) newax.axis('off') plt.show()
Output
- Related Articles
- How to zoom a portion of an image and insert in the same plot in Matplotlib?
- How to create a surface plot from a greyscale image with Matplotlib?
- How to plot a watermark image in Matplotlib?
- Matplotlib – How to insert a degree symbol into a Python plot?
- How to plot a layered image in Matplotlib in Python?
- How do you directly overlay a scatter plot on top of a jpg image in Matplotlib?
- How to plot additional points on the top of a scatter plot in Matplotlib?
- How to use a custom png image marker in a plot (Matplotlib)?
- How to plot a remote image from http url using Matplotlib?
- How to create a Swarm Plot with Matplotlib?
- How to plot a Pandas Dataframe with Matplotlib?
- How to plot a smooth line with matplotlib?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- How to show tick labels on top of a matplotlib plot?
- How to show (0,0) on matplotlib graph at the bottom left corner?

Advertisements