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.
\( \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 |
The following code show more examples of plotting three dimensional regions. You may want to move the figure around to see the entire shape!
![]() |
RegionPlot3D[x^2 + y^2 <= 16, {x, -4, 4}, {y, -4, 4}, {z, 0, 2},
BoxRatios -> Automatic, AxesLabel -> Automatic, PlotStyle -> Gray, Mesh -> 8] |
![]() |
RegionPlot3D[x^2 + y^2 <= 4, {x, 0, 2}, {y, 0, 2}, {z, 0, 3},
BoxRatios -> Automatic, AxesLabel -> Automatic, ColorFunction -> "BlueGreenYellow"] |
![]() |
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] |
![]() |
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:
![]() |
![]() |
![]() |
![]() |
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: