- 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 draw a log-normalized imshow plot with a colorbar representing the raw data in Matplotlib?
To draw a log-normalized imshow() plot with a colorbar representing the raw data in matplotlib, we can take the following steps −
- Create a 2D array using numpy.
- Display the data as an image, i.e., on a 2D regular raster, using imshow() method
- Create a colorbar for a ScalarMappable instance, *mappable*, using imshow() method.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt, cm from matplotlib import colors plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(4, 4) im = plt.imshow(data, cmap=cm.rainbow, norm=colors.LogNorm()) plt.colorbar(im) plt.show()
Output
- Related Articles
- How to plot data into imshow() with custom colormap in Matplotlib?
- How to plot a 2D matrix in Python with colorbar Matplotlib?
- How to plot scatter points in a 3D figure with a colorbar in Matplotlib?
- How to add a colorbar for a hist2d plot in Matplotlib?
- How to remove scientific notation from a Matplotlib log-log plot?
- How to plot a pcolor colorbar in a different subplot in Matplotlib?
- How to make a discrete colorbar for a scatter plot in matplotlib?
- Matplotlib – How to set xticks and yticks with imshow plot?
- How to disable the minor ticks of a log-plot in Matplotlib?
- How can I plot NaN values as a special color with imshow in Matplotlib?
- Setting the limits on a colorbar of a contour plot in Matplotlib
- How to plot an image with non-linear Y-axis with Matplotlib using imshow?
- How to plot contourf and log color scale in Matplotlib?
- How to draw axis lines inside a plot in Matplotlib?
- How to make a 4D plot with Matplotlib using arbitrary data?

Advertisements