Python also be used to create three-dimensional plots

 

Line Plots


We can use the code below to generate a 3D line plot

 

Scatterplot


We can use the code below to generate a 3D Scatterplot.

 

Surface Plots


We can use the code below to generate a Surface plot.

 

Quiver Plot


The code below plots a set of 3D arrows. The intial view angle of the plot can be rotated with the ax.view_init() function.

 

Contour Plot


The following code plots a 3D contour plot.

Example 1: The paraboloid example shows that any function with three variables can be visually represented in Python:

   ■

Example 2: The VectorPlot3D function is used to plot vector fields. Vector fields are used to represent equations that model many physical quantities such as the flow of liquid, strength of a force, and velocity of an object.

   ■
Example 3: Viviani's curve is called after the Italian mathematician and scientist Vincenzo Viviani (1622--1703). He was a pupil of Torricelli and a biographer of Galileo, who studied the curve in 1692) is the intersection of the cylinder \( (x-a)^2 +y^2 =a^2\) and the sphere \( x^2 + y^2 + z^2 = 4a^2\). It is parametrized by

\( \mbox{viviani}[a](t) = a (1+\cos t , \sin t, 2\sin (t/2)) \qquad (-2\pi \le t \le 2\pi ) \)

To plot the viviani curve, we first define its equation and then plot it


The three dimensional picture is obtained with the following code.
Vincenzo Viviani Intersection of a cylinder with sphere Viviani curve
Here is another variation of the viviani curve:
ParametricPlot3D[{Cos[t] Sin[t], (Sin[t])^2 , Cos[t]}, {t, 0, 2 Pi}]
   ■

Example 4: Some examples of three dimensional regions.

 

The following code show more examples of plotting three dimensional regions. You may want to move the figure around to see the entire shape!
    Pack.
RegionPlot3D[x^2 + y^2 <= 16, {x, -4, 4}, {y, -4, 4}, {z, 0, 2},
BoxRatios -> Automatic, AxesLabel -> Automatic, PlotStyle -> Gray, Mesh -> 8]

 

    Quarter of pack.
RegionPlot3D[x^2 + y^2 <= 4, {x, 0, 2}, {y, 0, 2}, {z, 0, 3},
BoxRatios -> Automatic, AxesLabel -> Automatic, ColorFunction -> "BlueGreenYellow"]

 

    Bowl.
RegionPlot3D[ x^2 + y^2 + z^2 <= 9 && x^2 + y^2 + z^2 >= 4,
{x, -3, 3}, {y, -3, 0}, {z, -3, 3},
BoxRatios -> Automatic, AxesLabel -> Automatic,
ColorFunction -> "DarkRainbow", MeshShading -> Automatic]

 

    Eighth part of the ball.
RegionPlot3D[x^2 + y^2 + z^2 <= 1,
{x, 0, 1}, {y, 0, 1}, {z, -1, 0},
BoxRatios -> Automatic, AxesLabel -> Automatic, ColorFunction -> Hue, MeshShading -> Automatic]
   ■

Example 5: Logarithmic functions are used to represent real world situations like population growth, decay of a substance, and financial interest rates. Most times these functions are shown in 2 dimensional spaces, but can still be represented in 3D.

Here is another version:

   ■

Example 6: Now we plot surface of revolution with respect to x-axis. Using the RevolutionPlot3D function, you can create a simple 2D function into a cool 3D shape:

 

Example 7: A catenoid is a type of surface, arising by rotating a catenary curve about an axis. It is a minimal surface, meaning that it occupies the least area when bounded by a closed space. It was formally described in 1744 by the mathematician Leonhard Euler. The catenoid may be defined by the following parametric equations:

\[ \begin{split} x(u,v) &= c\,\cosh \left( \frac{v}{c} \right) \cos u , \\ y(u,v) &= c\,\cosh \left( \frac{v}{c} \right) \sin u , \\ z(v) &= v , \end{split} \]
where u ∈ [-π,π) and v ∈ ℝ and c is a non-zero real constant.
A helicoid minimal surface formed by a soap film on a helical frame       A catenoid   A catenoid obtained from the rotation of a catenary Deformation of a helicoid into a catenoid

Example 8:

 

Example 9: Arrow plots can be used to show the direction of a line by adding arrows to the functions. Arrow Helix Plot: