- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set a colormap of an image in Matplotlib
63 Lectures 6 hours
To set a colormap of an image, we can take the following 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 your data.
- Display the data as an image, i.e., on a 2D regular raster with "hot" colormap
- Turn off the axes.
- To display the figure, use show() method.
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, cmap="hot") plt.axis('off') plt.show()
- How to set a default colormap in Matplotlib?
- How to extract a subset of a colormap as a new colormap in Matplotlib?
- Defining the midpoint of a colormap in Matplotlib
- Add alpha to an existing Matplotlib colormap
- How to reverse the colormap of an image to scalar values in Matplotib?
- Defining a discrete colormap for imshow in Matplotlib
- Extract Matplotlib colormap in hex-format
- Set two Matplotlib imshow plots to have the same colormap scale
- Set an image as a server-side image map in HTML?
- Plot a histogram with colors taken from colormap in Matplotlib
- Matplotlib Plot Lines with Colors through Colormap
- How to make the Parula colormap in Matplotlib?
- How to draw node colormap in NetworkX/Matplotlib?
- Set the height of an image with CSS
- Set the opacity of an image with CSS