- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 apply pseudo color schemes to an image plot in Matplotlib?
Pseudocolor can be a useful tool for enhancing the contrast and visualizing your data more easily. This is especially useful when making presentations of your data using projectors(because their contrast is typically quite poor).
Pseudocolor is only relevant to single-channel, grayscale, luminosity images. We currently have an RGB image. Since R, G, and B are all similar, we can just pick one channel of our data−
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Read an image from a file into an array.
- Pick one channel of our data.
- Display data as an image, i.e., on a 2D regular raster.
- Turn off the axes.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt, image as mimg plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True img = mimg.imread('bird.jpg') lum_img = img[:, :, 0] plt.imshow(lum_img) plt.axis('off') plt.show()
Output
- Related Articles
- How to plot an animated image matrix in matplotlib?
- How to plot a gradient color line in matplotlib?
- How to plot a watermark image in Matplotlib?
- How to plot contourf and log color scale in Matplotlib?
- How to plot a layered image in Matplotlib in Python?
- How to change the color of a plot frame in Matplotlib?
- Python Plotly – How to simultaneously apply color/shape/size in a Scatter Plot?
- Matplotlib – Plot over an image background in Python
- How to change the plot line color from blue to black in Matplotlib?
- How to plot a smooth 2D color plot for z = f(x, y) in Matplotlib?
- How to customize the color and colormaps of a Plot in Matplotlib
- How to plot with multiple color cycle using cycler property in Matplotlib
- How to plot a single line in Matplotlib that continuously changes color?
- How to apply Posterize to an image in Node Jimp?
- How to change the face color of a plot using Matplotlib?

Advertisements