Anda di halaman 1dari 57

Excel Charting Primer I

Charting Missing Data


Modifying Chart Series
Create a Chart with Series Formulas
Combination Charts
Use 2 Value Axes in a Chart
Graphical Fills
Dynamic Chart Titles
XY vs. Line Chart Types
Correcting Misleading Chart Scales
Managing Category Dates
Creating a Chart with Multiple Category Labels
Locate Chart Tick Marks
Adding Labels to XY and Bubble Chart Data Points
3-D Chart Basics

Many of the examples in this workbook were


adapted from the text named Excel Charts, by
John Walkenbach, Wiley, 2003.

3 Ways to Chart Missing Data

Charting Missing Data

Return to Contents

The three charts in this worksheet show three ways to handle missing data.
In the first chart the missing data is not plotted, in the second the missing
data is plotted as zeros, and in the third Excel interpolates the missing data.

The Data
Time Temperature
12:00 AM
28
1:00 AM
2:00 AM

27
27

60

3:00 AM
4:00 AM

24
26

40

5:00 AM
6:00 AM

32
35

20

7:00 AM
8:00 AM

38
40

9:00 AM
10:00 AM

45

11:00 AM
12:00 PM
1:00 PM

47
50
52

2:00 PM
3:00 PM

52
50

4:00 PM
5:00 PM

43

6:00 PM
7:00 PM

36
34

8:00 PM
9:00 PM

32
30

10:00 PM

29

11:00 PM

28

Temperature
Chart 1 - Missing Data Not Plotted

50

30

10
0

60

Temperature
Chart 2 - Missing Data Not Plotted as Zeros

50
40
30
20
10
0

60
50
40
30
20
10
0

Temperature
Chart 3 - Missing Data Interpolated

Manipulate Chart Series

Manipulate Chart Series

Return to Contents

Chart 1: A column chart using data in Data Range 1 with the quarterly sales values as
the data series and the regions as the categories. Change the Q1 Sales series name from
"Q1 Sales" to "Quarter 1 (Millions"). The plotting order is changed so the quarter 2 series
markers appear to the left of the quarter 1 series markers and "Q2 Sales" is the top row.
of the legend.
Chart 2: A copy of Chart 1 with these changes:
1) All series removed but North, South, East, and West.
2) North, South, East, and West data added for quarters 3 and 4 from Data Range 2.
3) Y-axis scale chaned from $0 to $70 to $0 to $80 and display labels by 20s on the axis
(that is, $0, $20, $40, $60, $80, and $100) instead of by 10s.
4) A chart data table added.
Data Range 1
Region
North
South
East
West
Central
NorthWest
NorthEast
SouthWest

Q1 Sales
$50
$45
$32
$58
$40
$35
$30
$38

Q2 Sales
$55
$42
$35
$50
$43
$35
$28
$45

SouthEast

$42

$48

Region
North
South
East
West
Central
NorthWest
NorthEast
SouthWest

Q3 Sales
$58
$41
$37
$49
$46
$37
$24
$47

Q4 Sales
$56
$40
$38
$52
$47
$34
$22
$48

SouthEast

$48

$45

Chart 1
$70
Q2 Sales

$60

Quarter 1 (Millions)

$50
$40
$30
$20
$10
$0

Data Range 2

Nor th

South

East

West

Centr al

Nor thWest

Nor thEast

SouthWest

Chart 2
$80

$60

$40

$20

$0
Nor th

South

Q2 Sales

East

Quarter 1 (M illions)

West

Q3 Sales

Q4 Sales

SouthEast

Creating a Chart by Writing Series Formulas

Create a Chart by Specifying its Series


The series function in the chart below generates the bar markers.

Return to Contents

The data for the chart doesn't exist anywhere but in the SERIES
statement, which is =SERIES(,{"Films","Books","Music"},{2, 9, 7},1).
Hours Per Week: Entertainment

The copy of the chart below has been modified to column from pie.
The SERIES formula has been changed so that Films, Books, and
Music constitute a single data marker with a total of 18 hours and Laundry,
Cooking, and Dusting are a second data marker with a total of 6 hours.
A legend has been included and functions as this chart's title.
Below is the text for the series function that will create this second chart.

=SERIES("Hours Per Week: Entertainment vs. Housekeeping",{"Films, Books & Music","Laundry, Cooking, & Cleaning"},{18,6},1)
When displaying the formula in the worksheet, precede the formula with
a single quote mark so Excel doesn't attempt to interpret the text as an
actual formula.

Hours Per Week: Entertainment vs. Housekeeping


15

10

* Note
To create a chart using only a series formula, start the Chart Wizard
Wizard as usual but without selecting any data beforehand. In the
Wizard's Step 1 select a chart type. Click the Wizard's Finish
button immediately. With the empty rectangle the Wizard has
allocated selected (Illustr. 1), click in Excel's Formula Bar enter the
series function that defines your chart. Excel creates the basic
chart (Illustr. 2). Add whatever formatting you like.

Illustr. 1

Illustr. 2

Combination Charts

Return to Cont

Create a combination chart by creating a standard chart first and then


converting one or more of the chart series to a different chart type.
Region
North
South
East
West
Central

Q1 Sales Q2 Sales Q3 Sales Q4 Sales


$50
$55
$60
$65
$45
$42
$39
$36
$32
$35
$38
$41
$58
$50
$42
$34
$40

$43

$46

$49

Column and Line Combination Chart

Column, Area, and Line Combination Chart

$80

$80

$60

$60

$40

$40

$20

$20

$0

$0
North
Q4 Sales

South
East
Q1 Sales

West
Q2 Sales

Central
Q3 Sales

North
Q3 Sales

Excel offers a few built-in combination charts on its Chart Wizard Step 1
on its "Custom Types" tab, but it's easy to customize your own combination.

South

East
Q4 Sales

West
Q1 Sales

Centra

Q2 Sale

Return to Contents

Combination Chart

st

West
Q1 Sales

Central
Q2 Sales

A Chart with Two Value Axes


When the data you're charting varies dramatically in scale,
a chart with two value axes may be the best solution.
The first chart on this worksheet uses a single value axis.
The second chart is modified so Income values use the left-hand
Y axis and Profit Margin values use a new right-hand Y axis.
The left-hand Y axis scale is changed so it ranges from 170,000
to 2,970,000 with a "Major Unit" of 700,000. The right-hand

March
April
May
June
July
August

Y axis scale is changed to start at 9%.

September

Data Charted With One Value Axis

$3,400,000

$2,550,000

$1,700,000

Income

$850,000

Profit Margin
$March

April

May

June

July

August

September

Data Charted With Two Value Axes


$2,970,000

15.0%
14.0%

$2,270,000

Income

$1,570,000

12.0%
11.0%

$870,000

Income
Profit Margin

$170,000
M arch

April

M ay

June

July

August

10.0%
9.0%
September

Profit Margin

13.0%

Income

$1,570,000

12.0%
11.0%

$870,000

Income
Profit Margin

$170,000
M arch

April

M ay

June

July

August

10.0%
9.0%
September

Profit Margin

13.0%

$
$
$
$
$
$

Income
2,455,682
2,022,515
1,899,588
2,450,385
2,885,626
1,993,285

Profit Margin
12.5%
11.2%
10.1%
14.5%
14.1%
13.2%

1,988,659

10.9%

15.0%
14.0%

12.0%
11.0%
10.0%
9.0%
tember

Profit Margin

13.0%

Return to Contents

12.0%
11.0%
10.0%
9.0%
tember

Profit Margin

13.0%

Examples of Charts with Graphical Fills


Line Chart Plot Area with Graphical Fill
$3,000,000

Plot Area with Graphical Fill and Cha


14.0%
12.0%

$2,500,000

10.0%

$2,000,000

$3,000,001

$2,500,001

8.0%
$1,500,000
6.0%
$1,000,000

4.0%

$500,000

2.0%

$-

$2,000,001

$1,500,001

$1,000,001

0.0%
March

April

May

$500,001

$1
March

Pie Chart with a


Graphic in One Slice

Quarter1

Quarter2

Apri

Chart with Forma

Quarter3

Copy a chart and paste special as a picture


from its underlying data. Ungroup the elem
A Graphic (Once a Chart)
Edited as a Picture

Chart Data

Apr
Feb
Mar

Quarter 1 Quarter 2 Quarter 3


12
3
56
145
5
44
16
88
67

Jun

May

Apr

Mar

Feb

January

10

Return to Contents

rea with Graphical Fill and Chart Series with Graphical Fill

$3,000,001

$2,500,001

$2,000,001

$1,500,001

$1,000,001

$500,001

$1
March

April

May

Chart with Formatted Legend

Quarter 1
Quarter 2
Quarter 3

hart and paste special as a picture to separate the chart


underlying data. Ungroup the elements to manipulate them.
A Graphic (Once a Chart)
Edited as a Picture

New Data
Old Data

10

20

30

40

50

60

Dynamic Chart Titles


Make chart titles dynamic if you want them to change
automatically as values in your worksheet change.

Feb
Mar

Q1
104
115

Q2

Q3
75
86

56
44

Referenced value: Southern


Concatenation:

(Change this value to change the c

Values from the Southern Region

Values from the Southern Region


120
Feb
Mar

80

40

0
Q1

Q2

Q3

How to create a dynamic chart title:


1. Create the chart, leaving off a main title.
2. Locate in a worksheet cell (or cells) the values you want
the title to take on. If using values from more than one cell,
create the title you want in another cell using Excel concaten
3. Select the chart.
4. Click in the formula bar, enter an equals sign, and reference
the cell that holds the title value or the concatenated value
you want. Hit the enter key.

Return to Contents

ge this value to change the chart title.)

uthern Region

s) the values you want


s from more than one cell,
er cell using Excel concatenation.

equals sign, and reference


or the concatenated value

The XY (Scatter) vs. the Line Chart

Data

The relationship between data points is best plotted with


an XY or Scatter plot for certain kinds of data. Below is
an XY chart type of the population data in this worksheet.
Below that is a line chart of the same data. The line chart
assumes the X axis is non-numeric and that the years are
equally spaced in the data, which is not the case. The line
chart gives a misleading view of the data.

Population Growth: XY Chart


Population (billions)

12
10
8
6
4
2
0

500
1000
1500
2000
Year (plotted against population figures)

Population Grow th: Line Chart


Population (billions)

12
10
8
6
4
2
0

Year (plotted as category values)

2500

Year
0
1000
1250
1500
1750
1800
1850
1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
1999
2000
2010
2020
2030
2040
2050
2100
2150

Data
Population
0.01
0.20
0.40
0.65
0.78
0.90
1.20
1.65
1.75
1.85
1.95
2.05
2.59
2.70
3.10
3.80
4.30
4.85
5.40
5.95
6.50
8.11
8.58
8.91
9.46
9.75

(billions)

Return to Contents

Misleading Scales/Consistent Chart Scales


If creating several charts of like data, it's often best to
make sure the chart scales remain the same so the data
can be compared accurately across charts. The first two
charts below appear to be charting data that's quite similar,
but this is because the value scales are different. See the
third chart below that uses the same scale as the first.
Survey Question 1 Responses (Scale 0-50%)
Unsatisfactory
Not Good

Survey Question 1 Responses


Excellent
Very Good
Good
Not Good
Unsatisfactory
Survey Question 2 Responses
Excellent
Very Good
Good
Not Good
Unsatisfactory

Good
Very Good
Excellent
0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0%

Survey Question 2 Responses (Scale 0-20%)

Unsatisfactory
Not Good
Good
Very Good
Excellent

0.0% 2.0% 4.0% 6.0% 8.0% 10.0% 12.0% 14.0% 16.0% 18.0%

This third chart is based on fewer responses. The scale of this chart matches the scale
of the first chart, making it easier to compare responses accurately across charts.
Survey Question 2 Responses (Scale 0-50%)

Unsatisfactory
Not Good
Good

Survey Question 2 Responses (Scale 0-50%)

Unsatisfactory
Not Good
Good
Very Good
Excellent

0.0%

10.0%

20.0%

30.0%

40.0%

50.0%

rvey Question 1 Responses


3.0%
4.9%
24.4%
41.5%
26.2%
100.0%
rvey Question 2 Responses
2.9%
4.0%
11.0%
16.0%
12.0%
45.9%

Return to Contents

The Date-Based Category Chart Axis


If you create a chart using time or date data as category data,
Excel automatically creates equal intervals between values
even if that means adding new category information to what
you're charting. For example, the chart below shows equally
spaced dates on the category (X) axis, although the data
itself (at right) does not have dates equally spaced.

Equally-spaced Dates Supplied by Excel

Sales (Thousands)

$0.0

$1.0

$2.0

$3.0

$4.0

$5.0

$6.0

$7.0

If you prefer you can turn off this Excel charting feature. Open the
"Chart Options" dialog for the chart and on the "Axes" tab change
the selected option for the category axis from "Automatic" to "Category".

Sales (Thousands)

Dates From the Data Only

10/28/2003

10/24/2003

10/23/2003

10/18/2003

10/12/2003

10/7/2003

Sale Date
10/5/2003
10/7/2003
10/12/2003
10/18/2003
10/23/2003
10/24/2003
10/28/2003

Dates From the Data Onl

10/24/2003

10/23/2003

10/18/2003

10/12/2003

10/7/2003

10/5/2003
$0.0

$1.0

$2.0

$3.0

$4.0

$5.0

$6.0

$7.0

Sales (Thousands)
$5.3
$4.5
$6.6
$5.8
$3.2
$5.1
$4.8

Return to Contents

Using Multiple Category Labels


Excel can recognize and use multiple rows or columns of category
values in a single chart.

Excel's Interpretation of the Data to Chart

Month
Contacts

25

20

15

10

China
Japan
Far East

Croatia
Russia
Eastern Europe

Canada
Mexico
West

To correct Excel's interpretation of the data, use the "Series" tab in the
"Source Data" chart dialog. Note that data used for the multiple category
names must be contiguous.

Multiple Category Labels Reinterpreted to include Months


25

Number of Contacts Made

20

15

10

10
11
China
Japan
Far East

10
11
Croatia
Russia
Eastern Europe

10
11
Canada
Mexico
West

Number of Conta

10

10
11
China
Japan
Far East

10
11
Croatia
Russia
Eastern Europe

10
11
Canada
Mexico
West

Category Labels
Region
Far East

Countries
China
Japan
Eastern Europe Croatia
Russia
West
Canada
Mexico

Month
10
11
10
11
10
11

Data to Chart
Contacts
15
16
12
10
18
23

Return to Contents

Controlling Chart Tick Mark Labels


With some charts you may want to override Excel's
standard positioning of tick mark labels

Standard Tick Mark Label Position


Tick Mark Position
10
8
6
4
2
0
1

-2
-4
-6

Use the "Format Axis" dialog and the "Patterns" tab to


control tick mark label positioning on a chart.

Tick Mark Labels Specified "Low"


10
8
6
4
2
0
-2
-4
-6
1

Data to Chart
-5
-3
-1
3
5
8

-2
-4
-6
1

Tick Mark Labels Specified "High"


1
10
8
6
4
2
0
-2
-4
-6

Return to Contents

Labeling XY and Bubble Chart Data Points


Excel has no way for you to specify a range of text to be used as
data labels for the values plotted in XY or Scatter charts. Labels
can be added manually, or third-party utilities are available to
make a labeling feature available to your XY chart. Microsoft also
provides instructions* on its Knowledge Base website for creating
a VBA program to add XY labels. That VBA code is used to label
the data points in the scatter and bubble plot examples here.

Netsuke Demand by Price and Model


- as XY (Scatter) Plot -

20

Demand

16

15
12

12

10
8

8
5

4
0
$20

$25

$30

$35

$40

$45

Price
* See http://support.microsoft.com/default.aspx?scid=kb;en-us;213750
SUMMARY
Excel has no built-in commandto automatically attach text labels to
data points in an xy (scatter) or Bubble chart. However, you can create a
Visual Basic for Applications macro that does this. Below is a macro that
performs this task on an XY Scatter chart. It can also be used for a Bubble Chart.
The sample code in this article assumes that the data and associated labels
are arranged in a worksheet according to the following format: The first
column contains the data labels. The second column contains the x values
for the xy (scatter) chart. The third and subsequent columns contain the y
values for the xy (scatter) chart.
NOTE: Although the example provided contains only one column of data for
y values, you can use more than one series of data.

To use the macro described here, create a chart using the following data:
A1:
A2:
A3:
A4:
A5:
A6:

Labels
DataPoint1
DataPoint2
DataPoint3
DataPoint4
DataPoint5

B1: X Values
B2: 12
B3: 9
B4: 5
B5: 4
B6: 1

C1: Y Values
C2: 5
C3: 7
C4: 3
C5: 8
C6: 4

NOTE: The table should not contain empty columns, and the column that contains the
data labels should not be separated from the column that contains the x values. The
labels and values must be laid out in exactly the format described in this article
(the location of the upper-left cell does not have to be cell A1).
To attach text labels to data points in an xy (scatter) chart, follow these steps:
- Create an XY chart in the usual fashion.
- Press ALT+F11 to open Excel's Visual Basic for Applications environment.
- On the VBA Insert menu, click Module to create a code window.
- Type the following sample code in the module sheet (or copy & paste from here):
Sub AttachLabelsToPoints()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
' Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(1).Formula
'Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, _
Mid(Left(xVals, InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(1).Points(Counter).HasDataLabel = _
True
ActiveChart.SeriesCollection(1).Points(Counter).DataLabel.Text = _
Range(xVals).Cells(Counter, 1).Offset(0, -1).Value
Next Counter
End Sub

- Press ALT+Q to return to Microsoft Excel.


- Select the chart.
- From Excel's menus choose Tools, Macro, Macros. Click AttachLabelsToPoints
and then click Run to run the macro.
The macro automatically associates the labels with the data points on the chart.

Netsuke
Kirin
Badger
Foo Dog
Bean Thrower
Mirror Polisher

Price
$22
$38
$32
$42
$28

Demand
8
12
10
5
15

Bubble Size**
Availability
3
5
4
1
8

Return to Contents

Netsuke Demand by Price, Model, & Availability


- as Bubble Chart -

Demand

16

12

$45

ubble Chart.

4
$15

$20

$25

$30
Price

$35

$40

** This column of data is used in the bubble chart only. The bubble size
gives a quick visual indication of the "availability" dimension in the data.

$45

that contains the


e x values. The

nvironment.

& paste from here):

",") - 1)

sDataLabel = _

ataLabel.Text = _

hLabelsToPoints,

nts on the chart.

Kirin

Badger

Foo Dog
Bean Thrower

Mirror Polisher

3-D Chart Basics


Excel has some built-in 3-D chart types. The 3-D chart here
is shown in six different views. Because it can be difficult
to select a 3-D chart element, remember that the Chart
Toolbar has a drop-down list of elements that can be used
for selection.

Chart Data
Year
2000
2001
2002

View 1: A standard 3-D column chart.

View 2: The "frame view" (


Select the chart "Corners"

Dogs Registered with the AKC by Breed

6,000

4,500
Labrador
Corgi
Bedlington

3,000

1,500

2000

2001

2002

View 4: The 3-D chart with a Z Value axis added. The data isn't all
visible in this view and with this arrangement of the data.

The "Chart Options" dialog

Dogs Registered with the AKC by Breed


6,000

4,500

3,000

1,500

Bedlington
Corgi

2000

Labrador

2001
2002

View 6: The data series modified so all data is visible; the chart rotated.

Dogs Registered with the AKC by Breed


6,000
4,500

3,000
1,500

Labrador
Corgi
2002

Bedlington

2001
2000

The "Format Data Series" d

Corgi
2002

Bedlington

2001
2000

Return to Contents

Chart Data
Labrador
2,030
4,325
5,112

Corgi Bedlington
524
82
638
104
929
203

View 2: The "frame view" (w/CONTROL depressed to show shapes).


Select the chart "Corners" element and use this view to control perspective.

View 3: The chart with perspective altered by dragging

Dogs Registered with the AKC by Bree


6,000

4,500

3,000

1,500

2000

2001

200

The "Chart Options" dialog "Axes" tab with all 3 axes selected.

View 5: An incomprehensible 3-D view of the data.

Dogs Registered with the AKC by B

3,000

6,000

2000

B
2001

Corgi
2002

The "Format Data Series" dialog with its "Series Order" tab.

Labrador

ective altered by dragging the Corners element.

with the AKC by Breed

Labrador
Corgi
Bedlington

2001

2002

Use the "Chart Options" "3-D View" dialog and its Default
button to return the chart to a standard perspective.

3-D view of the data.

ed with the AKC by Breed

Bedlington

Corgi
2002

Labrador

Anda mungkin juga menyukai