Peltier Tech Blog

Excel Chart Add-Ins | Training | Custom Solutions | Charts and Tutorials | PTS Blog

 

Main menu:

 
Peltier Tech
Chart Add-Ins

Peltier Tech Waterfall Chart Utility
Peltier Tech Cluster-Stack Chart Utility
Peltier Tech Box and Whisker Chart Utility
Peltier Tech Marimekko Chart Utility
Peltier Tech Dot Plot Utility
Peltier Tech Cascade Chart Utility

 
Excel Dashboards

Subscribe

Site search

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Category Axis Tricks for Line and Area Charts – 1

by Jon Peltier
Friday, June 6th, 2008
Peltier Technical Services, Inc., Copyright © 2010.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Let’s look at the behavior of line charts and the category axis. Here is some simple data I made up just for this exercise, and a typical line chart plotting the data.

 

 

 

Value
1 11
2 7
3 12
4 7
5 15
6 13
7 16
8 12
9 17
10 16
11 18

 

 

 

Okay, not too boring. Let’s see what happens if we split the data into two series, red and blue. The red series will include points 1 to 5, and the blue will include points 5 to 11. This is how we might plot actual and predicted data on the same chart, or perhaps data by quarter or year in separate series.

That didn’t do what we wanted or expected. In a chart type that relies on a category-type axis (line, area, column charts), all series use the same category data as the first series; in an XY chart, each series can have independent X values, and the X axis is a value-type axis. The first series has five data points (five category values, 1 to 5), while the second series has seven data points (5 to 11). The chart then has seven category values across the X axis, but only the first five (defined by the first series) have labels to display. The second series starts at the first category, like the first series, even though we would expect them to line up according to category values; an XY chart lines up in the way we would expect. We could just use an XY chart for this, but there are times when a line chart is preferred.

To align the two line series appropriately, we need the same number of category values, and we need to make sure the Y values are lined up with the corresponding category value. We accomplish this by splitting the values into two columns, red and blue; the red range has values in the top part and blanks below, while the blue range has blanks at the top and values below.

 

Table Arrangement for Two-Toned Line Chart, with Chart

 

 

Red Blue
1 11
2 7
3 12
4 7
5 15 15
6 13
7 16
8 12
9 17
10 16
11 18

 

 

 

The line chart works fine, one series starting where the other leaves off. By default, no points are plotted where there are blanks in the table. If you are using formulas to generate this data, you need to adjust the formula to use NA(), which is not plotted in a line or XY chart, and not “”, which is plotted as a zero value.

In fact, this is the basis for conditional charts, charts which display different formatting based on certain conditions being met. There is no conditional formatting built into Excel charts, but it can be simulated using multiple series and formulas or named ranges.

To get our two-color chart, we can design a table as follows. The original data is in columns A and B. Columns C and D will have formulas to define the chart series data. Cell E2 contains a cut-off value, below which we want to see the red series, above which the blue. The formulas in cells C2 and D2 are:

=IF(A2<=$E$2,B2,NA())
 

and

=IF(A2>=$E$2,B2,NA())
 

These formulas are filled down through row 12. Both <= and >= are used in the formulas, because we want both series to plot the shared point; if we used <= and =, we would have a gap after the cut-off point; if we used = and >=, the gap would occur before the cut-off. If we create the chart with the data in columns A, C, and D, we will get a chart just like the one plotting the previous data arrangement. However, if we change the value in cell E2, the point that divides red from blue will move left or right.

 

Table for Conditional/Dynamic Chart

 

A B C D E
1 Value Red Blue Cut-Off
2 1 11 11 #N/A 5
3 2 7 7 #N/A
4 3 12 12 #N/A
5 4 7 7 #N/A
6 5 15 15 15
7 6 13 #N/A 13
8 7 16 #N/A 16
9 8 12 #N/A 12
10 9 17 #N/A 17
11 10 16 #N/A 16
12 11 18 #N/A 18

 

 


Conditional/Dynamic Chart for Cut-Off Values of 3, 5, and 8.

This technique is extended to area charts in Category Axis Tricks for Line and Area Charts – 2

 

Related Posts:

Bookmark and share this entry:
  • Twitter
  • Digg
  • Facebook
  • LinkedIn
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • MySpace
  • Slashdot
  • Yahoo! Buzz
  • Tumblr

Learn how to create Excel dashboards.

Comments


Comment from Alvaro Ledesma
Time: Friday, June 6, 2008, 9:41 am

Jon, there is a small error in your description of what are you doing:

“Let’s see what happens if we split the data into two series, red for the first five rows, and blue for the remainder of the data.”

“The first series has five data points (five category values), while the second series has seven data points.”

You only have 11 data point in your example. Doing what you say in paragraph 1 does not gives you 12 data ponts unless you indicate that you are using data point 5 in both series (which is what happens when you split data points in two columns).

Just a very picky remark, I guess!

I really enjoy reading your feed.

Regards,

Alvaro


Comment from Jon Peltier
Time: Friday, June 6, 2008, 9:47 am

Alvaro – The fifth point is used by both series. This can be seen in the data and in the chart. But you’re right, I will clarify the explanation.

Write a comment

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.

Read the PTS Blog Comment Policy.





Subscribe without commenting

Peltier Tech Waterfall Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

Create Excel dashboards quickly with Plug-N-Play reports.