- 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
Displaying different images with actual size in a Matplotlib subplot
To display different images with actual size in a Matplotlib subplot, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Read two images using imread() method (im1 and im2)
- Create a figure and a set of subplots.
- Turn off axes for both the subplots.
- Use imshow() method to display im1 and im2 data.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True im1 = plt.imread("bird.jpg") im2 = plt.imread("opencv-logo.png") fig, ax = plt.subplots(nrows=1, ncols=2) ax[1].axis('off') ax[1].imshow(im1, cmap='gray') ax[0].axis('off') ax[0].imshow(im2, cmap='gray') plt.show()
Output
- Related Articles
- Changing Matplotlib subplot size/position after axes creation
- How to plot a pcolor colorbar in a different subplot in Matplotlib?
- Matplotlib legends in subplot
- Reading and displaying images using OpenCV
- Stuffing a Pandas DataFrame.plot into a Matplotlib subplot
- How to rotate tick labels in a subplot in Matplotlib?
- How can I programmatically select a specific subplot in Matplotlib?
- Displaying bar graphs using Matplotlib
- Rotating axis text for each subplot in Matplotlib
- Setting active subplot using axes object in Matplotlib
- Python - Working with PNG Images using Matplotlib
- How to Convert Image URLs to Actual Images in Excel?
- How to make longer subplot tick marks in Matplotlib?
- Displaying horizontal bar graphs using Matplotlib
- How to add a 3d subplot to a matplotlib figure?\n

Advertisements