- 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 plot a layered image in Matplotlib in Python?
To plot a layered image in Matplotlib in Python, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create dx, dy, x, y and extent data using numpy.
- Create a new figure or activate an existing figure using figure() method.
- Create data1 and data2 to display the data as an image, i.e., on a 2D regular raster.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True dx, dy = 0.05, 0.05 x = np.arange(-3.0, 3.0, dx) y = np.arange(-3.0, 3.0, dy) extent = np.min(x), np.max(x), np.min(y), np.max(y) fig = plt.figure(frameon=False) data1 = np.random.rand(5, 5) plt.imshow(data1, cmap="plasma", interpolation='nearest', extent=extent) data2 = np.random.rand(5, 5) plt.imshow(data2, cmap="copper", alpha=.9, interpolation='bilinear', extent=extent) plt.show()
Output
- Related Articles
- How to plot a watermark image in Matplotlib?
- How to a plot stem plot in Matplotlib Python?
- Matplotlib – Plot over an image background in Python
- How to plot an animated image matrix in matplotlib?
- How to use a custom png image marker in a plot (Matplotlib)?
- How to plot a density map in Python Matplotlib?
- How to plot a multivariate function in Python Matplotlib?
- How to plot signal in Matplotlib in Python?
- How to plot cdf in Matplotlib in Python?
- How to plot a phase spectrum in Matplotlib in Python?
- How to plot MFCC in Python using Matplotlib?
- How to plot vectors in Python using Matplotlib?
- How to apply pseudo color schemes to an image plot in Matplotlib?
- How to save a plot in Seaborn with Python (Matplotlib)?
- How to plot a remote image from http url using Matplotlib?

Advertisements