Skip to main content

Matplotlib: 3D Contour Plot

There is a function ax.contour3D() that can be used to create a 3-D function. It takes input data in the form of two-dimensional regular grids, with its Z-data evaluated at each point.


from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt

a= np.linspace(-0.1,10,100)
a,b= np.meshgrid(a,b) 

fig = plt.figure()

ax = fig.add_subplot(121, projection='3d')
ax.contour(a,b,c, 100)
ax.set_title('3D contour')

Here is the explanation of the some function used in the above example are:

  • meshgrid: This is the function of numpy which is basically used to create a rectangular grid out of two given one-dimension arrays representing Matrix Indexing.
  • plt.axes(): It is used to create the axis of the object.
  • ax.contour3D: It is used to create contour.
  • ax.set_xlabel: It is used to label the X-axis.
  • ax.set_title: It is used to give a title to the plot.


countour plot

Submitted by devanshi.srivastava on December 7, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.