How to scale axes in Mplot3d?

MatplotlibPythonData Visualization

To scale axes in mplot3d, we can take the following steps −

  • Create a figure or activate an existing figure using figure() method.

  • Instantaite 3D axes instance using Axes3D() class.

  • To scale X-axis, use set_xlim3d() method.

  • To scale Y-axis, use set_ylim3d() method.

  • To scale Z-axis, use set_zlim3d() method.

  • To display the plot, use show() method.

Example

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlim3d(-100, 100)
ax.set_ylim3d(-100, 100)
ax.set_zlim3d(-100, 100)
plt.show()

Output

raja
Published on 12-May-2021 11:56:33
Advertisements