Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Charts and Graphs 31

b. Select the replacement data cells to be added as described in Section 3.4. These
replacement cells may be chosen to include or omit the old data cells. To add a
data series while retaining the old data, see Section 3.6.
4. Click the collapse (expand) button again and the Select Data Source dialog box
will reappear.
5. Click OK, which will redraw the chart with the new replacement data.
6. Make cosmetic and other adjustments to the chart as needed.

3.6 Adding Data to Charts


Data can be added to charts as follows:

1. Activate the chart. The Chart Tools menu options will appear on the Ribbon Bar.
2. Click CHART TOOLS/DESIGN/DATA/Select Data. A Select Data Source popup
window will appear as in Figure 3.3. The lower left area of the Select Data Source
popup window is where you will click Add to add another data series using the
Edit Series dialog box that appears as shown in Figure 3.4.
3. In the Edit Series dialog box, select a name for the data series. Use the collapse/
expand button if needed.
4. After selecting a name for the data series, select the Series X and Y values, again,
using the collapse/expand button as needed.

Expand/collapse button

FIGURE 3.4
32 What Every Engineer Should Know About Excel

FIGURE 3.5

5. After completing the selections, click OK. The Select Data Source popup will reap-
pear with the additional data series listed, and the chart will be updated with the
additional data series plotted in the chart as shown in Figure 3.5.
6. Make cosmetic and other adjustments to the chart as needed.

3.7 Adding Trend Lines and Correlation Equations to Scatter Charts


To add a trend line, rst click on the chart to activate it. In the upper-right corner of the
chart, click the “+” sign to add a chart element. In the popup, select Trendline for a standard
linear trend line, or select the right arrow to pick a type of trend line (Linear, Exponential,
Linear Forecast, or Two Period Moving Average). Upon selecting the type, a prompt for
additional information will appear. In the case of a simple x–y linear trend line, the prompt
asks for the desired axis for the trend line—x or y.
When a trend line is added to a chart, Excel automatically calculates its R2 value. To
display an equation for the trend line and its R2 value, double click the trend line on the
chart to bring up a Format Trendline window. Toward the bottom of that window, there
Charts and Graphs 33

are two choices: Display Equation on chart and Display R-squared value on chart. Select
from those two choices to display the items. See Sections 3.9 and 3.10 for speci c examples.

3.8 Equation for R 2


The equation employed by Excel for calculating R2 in the trend line ts is given by
2
R 2 =  n ∑ x i y i − ∑ x i ∑ y i  / n ∑ x 2i − ∑ x i  n ∑ y 2i − ∑ y i 
2 2
(3.1)

R2 is called the coef cient of determination, whereas R is called the correlation coef cient.
This equation expresses what is called the Pearson correlation coef cient, which is demon-
strated by the PEARSON worksheet function. A calculation of R2 separate from the trend
line determinations may also be obtained by calling either the worksheet function RSQ
or PEARSON. Use the Excel Help facility for the proper syntax of these functions. The R2
displayed with the graphical trend line is expressed as follows:

SSE
R2 = 1 −
SST

where SSE is the sum of the squares of the error from the correlating trend line, or

SSE = ∑(y i − y ic )2

and SST is the sum of squares of deviations from the arithmetic mean, ymean = (∑yi)/n, and
may be expressed in the form:
2
SST = ∑ y 2i − ∑ y i /n

where yic represents the value of y on the linear trend line t. For a perfect match between
the data points yi and the trend line, R2 = 1.0. For exponential, power, and polynomial
trend lines, Excel uses a transformed regression model. Note that these calculations are
equivalent to using a population standard deviation instead of a sample standard devia-
tion. Still, a perfect t will be obtained when yi = yic. SST may also be calculated in terms of
the population standard deviation function STDEVP through the relation:

SST = n × [STDEVP(y i )]2

3.9 Correlation of Experimental Data with Power Relation


Several physical phenomena follow a power law relation between variables. Examples are
as follows:
Nu = C Re n
34 What Every Engineer Should Know About Excel

for forced convection and

Nu = C(GrPr)m

for free convection heat transfer. The general power law relation has the form

y = ax b (3.2)

Taking the logarithm of both sides of the equation gives

log y = log a + blog x (3.3)

which is a linear relation between log y and log x. When x and y are plotted on a log–log
graph, b will be the slope of the line and log a will be the intercept at x = 1.0 (see Section
3.10). When trying to t the experimental data with the power law relation, scatter in the
data will normally occur and a least-squares analysis should be employed to determine
the best t. A correlation coef cient may also be calculated to indicate the goodness of t.
Excel may be used to (1) display the data on a log–log plot, (2) calculate the values of the
constants a and b using a least-squares analysis, (3) display the resultant correlation trend
line, and (4) display the correlation equations on the plot.
Performing these steps in Excel, the procedure is as follows:

1. List the data in two columns. Label columns as appropriate. Consider discarding
any data points that appear to be in gross error. This step may be deferred until
after the data plot is obtained. See step 7.
2. Select the data to be plotted.
3. Click INSERT/CHARTS/Scatter and select the scatter chart without connecting the
line segments (type 1 chart).
4. Click the chart to be edited. Double click either the x- or y-value axis—a FORMAT
AXIS window will appear on the right side of the Excel worksheet. Under AXIS
OPTIONS, select the upper and lower bounds for the axis as well as the major and
minor units on the axis scale. Click Logarithmic Scale and the desired base (10
is default). Repeat for the other value axis. If desired, expand the TICK MARKS,
LABELS, and NUMBER options and select the desired options for each axis.
5. Once step 4 is completed, click the chart again. Then, click CHART TOOLS/
DESIGN/CHART LAYOUTS/Add Chart Element/Trendline/More Trendline
Options. Under Trendline Options, select Power, and click Display Equation on
the chart and Display R-squared value on the chart. The chart will automatically
update with the trend line, the equation, and the R2 value.
6. Inspect the nal graph. Does the trend line appear to represent the data? If not, the
power relation may not be correct for the physical application. This step is important!
A correlation equation should NEVER be accepted without visual con rmation of agree-
ment with the experimental data points. The computer will perform the trend line anal-
ysis as instructed, but it cannot assure that the functional form selected is correct.
7. Examine the individual data points in the nal plot. If some points appear to be
widely scattered from the main body of data, consult the original data sheets for
possible errors or erratic behavior in the experiment. Consider eliminating suspi-
cious points.
Charts and Graphs 35

8. If a decision is made to eliminate points as discussed in step 7, delete the respective


entries in the data cells. The deletions will appear on the chart, and a new trend line
and correlation equation will be displayed, based on the remaining data points.
9. Make nal adjustments to the cosmetics of the chart, fonts, titles, etc. If a large
number of data points are involved, some adjustments in the size of data markers
or in the line width for the trend line may be in order.

Two examples of power law correlation plots are shown in Figure 3.6. One has a rather
good t, whereas the other has a lot of scatter. In the latter case, one should suspect that
either the data are bad or that a power law relation does not t the physical situation.

FIGURE 3.6
36 What Every Engineer Should Know About Excel

3.10 Use of Logarithmic Scales


The data are rst plotted on a linear graph as shown in Figure 3.7a, indicating a decay-
ing exponential or inverse power relation. Logarithmic scales are then selected by double
clicking on each value axis. A FORMAT AXIS window will appear on the right side of the
Excel worksheet. Under AXIS OPTIONS, select the upper and lower bounds for the axis
as well as the major and minor units on the axis scale. Click Logarithmic Scale and the
desired base (10 is default). Remember to repeat for the other value axis. For the y-axis, in
the FORMAT AXIS section labeled “Horizontal axis crosses,” set the “Axis value” eld to
0.1 (the lower edge of the graph), and the result is shown in Figure 3.7b. Next, a trend line is
added by clicking on the chart. Then, click CHART TOOLS/DESIGN/CHART LAYOUTS/
Add Chart Element/Trendline/More Trendline Options. Under Trendline Options, select
Power, and click Display Equation on the chart and Display R-squared value on the chart.
The chart will automatically update with the trend line, the equation, and the R2 value.
The result is shown in Figure 3.7c. Visual inspection indicates that a power relation does
indeed t the data.

(a)

FIGURE 3.7
(Continued)

You might also like