Show Sidebar Hide Sidebar

Make a 3D Line Graph

A Step by Step Guide to Making a 3D Line Graph

Make a 3D Line Graph

Most graphs have two axes, often referred to as the x and y axis. We use a graph to understand the relationship between these two variables. A 3-dimensional graph lets you introduce a third axis, typically called the z axis, and can help you to understand the relationship between all three variables.

Three-dimensional line graphs are often used by mathematicians and scientists to draw functions of two variables. For example, a helix is a smooth curve in 3 dimensions with a spiral shape that is common in biology. Mathematically, we can describe a helix using parametric equations, that is, as three functions of a single parameter, often labeled $t$. The example that we’ll use in this tutorial is the following:

\left\{ \begin{aligned} x(t) &= \cos(t) \quad\\ y(t) &= \sin(t) \quad\\ z(t) &= t \end{aligned} \right.

Step 1: Set up the grid

We’re going to set up the grid with three columns of data, each representing one of the functions of $t$ above. If you want a shortcut, you can find the data at: https://plot.ly/~mariahh/71.

 To start, visit the Plotly workspace at https://plot.ly/plotSelect +NEW, and then Grid. Select 3d line plots from the MAKE A PLOT menu.The instructions in the sidebar explain the structure of the data we will need to produce. First, we will generate the $z(t)=t$ values using the Generate x-values option in the DATA TOOLS menu. We’re going to plot two periods of the helix. Since the helix described above has period $t$ values between 0 and ~12.57. We generate 200 values. We can rename the column of data by clicking on the arrow next to the title “Linear scale”. Select Rename, and type in the label for your column. To generate values for $y(t)$, we will again use Plotly’s built-in data tools. From the DATA TOOLS menu, select Formulas f(x). To generate the values for $x=t$. To tell Plotly which values we want to apply the cosine function to, we select choose as x just below the label “t” in the first column of the grid.Click Run in the Formulas f(x)sidebar to generate the $x(t)$ values.We follow the same steps to produce the values for $\sin(x)$ in the sidebar. Finally, select 3d line plots from the MAKE A PLOT menu. Choose the column “t” as z, column “sin(t)” as y, and “cos(t)” as x.Click the blue button in the sidebar to create the plot.

Step 2: Style it

 Your plot should look something like this.
 Open the TRACES popover in the toolbar. Using the Style tab you can change the style, thickness and color of the helix.To close the Traces popover, click on the “X” in the upper right.
 You can add a title by clicking on Click to enter Plot title.
 Wait, there’s more! In the LAYOUT popover, we can change the Scene color, the margin color, the font of the title and more.
 Want to see the original points that generated your 3d line plot? Go back to the TRACES popover. Change the Lines/Markers to the dot with line.