Tip:
Highlight text to annotate it
X
In this lesson, we will be learning how to create simple plots in Excel.
One of the nicest features about Excel is its ability to plot data very easily.
In this example, we are going to plot SIN(X) and COS(X) from X=0 to X=pi.
First, we need to create a column of values ranging from X=0 to X=pi.
We will use a small step size of pi/10 to ensure the data curves look smooth.
Underneath the column heading X, type 0 in cell A2.
We want the value to X to increase by pi/10 in each subsequent row.
This can be accomplished by clicking on cell A3 and entering the formula: =A2+PI()/10
PI() is a built-in function that has no arguments and returns the value of pi, which is 3.14159 and so on.
Notice that the formula =A2+PI( )/10 uses relative references.
This formula is translated as: “take the value in the cell that is directly above the current cell and add pi/10 to it.”
Every time we copy and paste the formula to the next row, we add pi/10 to the running total.
We can use the Fill Handle to calculate the remaining values of X up to pi.
In cell B2, enter the formula: =SIN(A2) In cell C2, enter the formula: =COS(A2)
The formula in cell B2 means: “take the value in the cell that is one column to the left and in the same row as the current cell, and use it as
the argument for the SIN function.”
The formula in the cell C2 means: “take the value in the cell that is two columns to the left and in the same row as the current cell, and use
it as the argument for the COS function.”
Use the Fill Handle to calculate SIN(X) and COS(X) for all the values of X in the left column.
Notice how the value of SIN(A12) and COS(A7) are almost zero.
This is because the number pi, like most numbers with decimals, cannot be represented exactly in binary, which is the numerical system
used by the computer.
Fortunately, 1.2E-16 and 6.1E-17 are close enough to zero for engineering applications.
Now we can plot SIN(X) versus X and COS(X) versus X.
We highlight the values that we want to plot.
Click on A1 and drag the cursor over all the values in the table.
Go to Insert at the top of the screen and select Scatter.
We then select the type of scatter plot that we want to create.
In this case, I will select a scatter plot where the points are connected by a curved line.
A chart appears that has a legend.
We can resize the chart by going to one of the corners and dragging the cursor.
You can add features to your chart by going to the Layout tab at the top of the screen.
Let’s add a chart title.