How to change angle of 3D plot in Python?
In this article, we will see how can we can view our graph from different angles, Here we use three different methods to plot our graph. Before starting let’s see some basic concepts of the required module for this objective.
- Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack
- Numpy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python
- mpl_toolkits provides some basic 3D plotting (scatter, surf, line, mesh) tools.
- Import required library.
- Create a figure.
- Create a datasheet.
- Change angle of the 3D plot
- Show Graph.
Step 1: Import libraries.
Step 2: Plotting 3-D axis figure.
Step 3: Creating a Datasheet for all the 3-axis of the sample.
Step 4: Use view_init() can be used to rotate the axes programmatically.
Syntax: view_init(elev, azim)
- ‘elev’ stores the elevation angle in the z plane.
- ‘azim’ stores the azimuth angle in the x,y plane.D constructor.
Below is the full Implementation:
Example 1: In this example, we will plot a curve graph with an elevated angle of -140 degrees and a horizontal angle of 60 degrees.
Example 2: In this example, we will plot a curve graph with an elevated angle of 120 degrees and a horizontal angle of 30 degrees.
Example 3: In this example, we will plot a rectangular plate graph with an angle view of 50 degrees.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course