Python Data Science Tutorial on Python 3D Charts

python is also capable of creating 3d charts. it involves adding a subplot to an existing two-dimensional plot and assigning the projection parameter as 3d.

drawing a 3d plot

3dplot is drawn by mpl_toolkits.mplot3d to add a subplot to an existing 2d plot.

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt


chart = plt.figure()
chart3d = chart.add_subplot(111, projection='3d')

# create some test data.
x, y, z = axes3d.get_test_data(0.08)

# plot a wireframe.
chart3d.plot_wireframe(x, y, z, color='r',rstride=15, cstride=10)

plt.show()
 

its output is as follows −

3dplot.png