- 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 can I display an np.array with pylab.imshow() using Matplotlib?
To display an np.array with imshow(), we can take the following steps
- Set the figure size and adjust the padding between and around the subplots.
- Make a 2D data raster using an np.array.
- Display the data as an image, i.e., on a 2D regular raster.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.array( [[0.1, 0.7, 0.6, 0.3], [0.2, 0.6, 0.5, 0.2], [0.8, 0.3, 0.80, 0.01], [0.3, 0.4, 0.2, 0.1]] ) plt.imshow(data, interpolation="nearest", cmap="RdYlGn_r") plt.show()
Output
- Related Articles
- How can I display an image using Pillow in Tkinter?
- How can I display an image using cv2 in Python?
- How can I display text over columns in a bar chart in Matplotlib?
- How can I render 3D histograms in Python using Matplotlib?
- How can I draw a scatter trend line using Matplotlib?
- How do I customize the display of edge labels using networkx in Matplotlib?
- How can I create a stacked line graph with matplotlib?
- How can I make a simple 3D line with Matplotlib?
- How can I display an image inside SVG circle in HTML5?
- How can I format a float using matplotlib's LaTeX formatter?
- How do I redraw an image using Python's Matplotlib?
- How to display a sequence of images using Matplotlib?
- How can I display Toast messages from a thread in Android using Kotlin?
- How can I get the output of a Matplotlib plot as an SVG?
- How can I plot hysteresis threshold in Matplotlib?

Advertisements