- 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 visualize scalar 2D data with Matplotlib?
To visualize scalar 2D data with matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Initialize a variable, N, for data samples.
- Create x and y data points using numpy.
- Get coordinate matrices from coordinate vectors.
- Get z data points using numpy.
- Create a pseudocolor plot with a non-regular rectangular grid.
- 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 n = 256 x = np.linspace(-3., 3., n) y = np.linspace(-3., 3., n) X, Y = np.meshgrid(x, y) Z = X * np.sinc(X ** 2 + Y ** 2) plt.pcolormesh(X, Y, Z, cmap='copper', shading='flat') plt.show()
Output
- Related Articles
- How to plot 2D math vectors with Matplotlib?
- How to visualize 95% confidence interval in Matplotlib?
- How to plot a 2D matrix in Python with colorbar Matplotlib?
- How can Tensorflow be used with estimators to visualize the titanic data?
- How to plot a 2D histogram in Matplotlib?
- How to plot 2d FEM results using matplotlib?
- How to Visualize API results with Python
- How can Tensorflow be used with Estimators to visualize the data, and the ROC curve?
- How can Tensorflow be used to visualize the data using Python?
- How to visualize a data frame that contains missing values in R?
- How can factorplot be used in Seaborn to visualize data in Python?
- How can FacetGrid be used to visualize data in Python Seaborn Library?
- Colorplot of 2D array in Matplotlib
- How to make a 4D plot with Matplotlib using arbitrary data?
- How to plot data into imshow() with custom colormap in Matplotlib?

Advertisements