- 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 obtain 3D colored surface via Python?
To obtain 3D colored surface via Python, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Get 3D data, i.e., z.
Create a new figure or activate an existing figure.
Get the 3D axes.
Create a surface plot.
To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-3, 3, 100) y = np.cos(x) x, y = np.meshgrid(x, y) z = x ** 2 + y ** 2 - 2 fig = plt.figure() ax = plt.axes(projection='3d') surf = ax.plot_surface(x, y, z, cmap=plt.get_cmap('hot'), edgecolor='none') plt.show()
Output
It will produce the following output −
- Related Articles
- Surface Area of 3D Shapes in Python
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- Find the Surface area of a 3D figure in Python
- Plot a 3D surface from {x,y,z}-scatter data in Python Matplotlib
- How to plot 3D graphs using Python Matplotlib?
- How to convert a colored image to HLS in OpenCV using Python?
- OpenCV Python – How to convert a colored image to a binary image?
- How to make a 3D scatter plot in Python?
- Python program to create 3D list.
- Python – 3D Matrix to Coordinate List
- How to create colored Venn Diagrams?
- How to access nested Python dictionary items via a list of keys?
- How to view a list of all Python operators via the interpreter?
- How to plot a 3D density map in Python with Matplotlib?
- Plotting a 3D surface from a list of tuples in matplotlib?

Advertisements