- 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 get smooth interpolation when using pcolormesh (Matplotlib)?
To get smooth interpolation when using pcolormesh, we can use shading="gouraud" class by name.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create data, x and y using numpy meshgrid.
Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.
To display the figure, use show() method.
Example
import matplotlib.pylab as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.random((3, 3)) x = np.arange(0, 3, 1) y = np.arange(0, 3, 1) x, y = np.meshgrid(x, y) plt.pcolormesh(x, y, data, cmap='RdBu', shading='gouraud') plt.show()
Output
- Related Articles
- How to animate a pcolormesh in Matplotlib?
- How to plot a smooth line with matplotlib?
- How to get a Gantt plot using matplotlib?
- How to draw a precision-recall curve with interpolation in Python Matplotlib?
- How to implement ‘cubic’ 1-D interpolation using SciPy library?
- How to get alternating colours in a dashed line using Matplotlib?
- How to plot a smooth 2D color plot for z = f(x, y) in Matplotlib?
- C++ program to implement Inverse Interpolation using Lagrange Formula
- How to draw a smooth line following my finger using Kotlin?
- How to create a smooth image rotation in Android using Kotlin?
- How to do string interpolation in JavaScript?
- How to remove the outline of a circle marker when using pyplot.plot in Matplotlib?
- How to get boxplot data for Matplotlib boxplots?
- How to get XKCD font working in Matplotlib?
- How to get an interactive plot of a pyplot when using PyCharm?

Advertisements