shading certain months on time chart

B

Bob Richardson

I have several years of data - the x-axis is a time-scale. I'd like to have
the winter months of the year shaded - to make it easier to see the
seasonality in the data. Is there a way to pick a period each year (e.g.
Nov. 15 - March 15) which will be shaded?
 
B

Barb Reinhardt

The easiest way to do this is to have a series of data for the winter months
only. That way you can shade that series differently.
 
T

Tushar Mehta

Here's how I would do it. For one application see the 'Overview by
Day' page of the newsgroup stats (http://www.tushar-
mehta.com/excel/ngstats/overview-daily.html)

Suppose the months are in column A and the y-values in column B as in:
1-Jan 6
1-Feb 8
1-Mar 11
1-Apr 10
1-May 13
1-Jun 11
1-Jul 9
1-Aug 16
1-Sep 12
1-Oct 14
1-Nov 12
1-Dec 19
1-Jan 17
1-Feb 21
1-Mar 19
1-Apr 20
1-May 20
1-Jun 24
1-Jul 28
1-Aug 24
1-Sep 21
1-Oct 22
1-Nov 25
1-Dec 25

Then, in column C (C1 specifically) enter the formula
=IF(OR(MONTH(A1)<=3,MONTH(A1)>=11),MAX($B$1:$B$24),NA())

Obviously, you would adjust the above formula for your specific needs.
This one 'shades' Nov.-Mar.
Copy C1 as far down col. C as there is data in column B.

Plot A:C as a column chart. Click the plotted series corresponding to
column B. Select Chart | Chart Type... and change it to a Line chart.

Double-click the plotted series corresponding to col. C. From the
Patterns tab, set the border to none and the area to some light color.
From the Options tab set the Gap Width to zero.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
B

Barb Reinhardt

If you want between November 15th and March 15th, you might need an equation
like this one.

=IF(OR(VALUE(MONTH(B1)&DAY(B1))>1115,VALUE(MONTH(B1)&DAY(B1))<315),B1,NA())

This is for data > 11/15 and < 3/15.
 
J

John Cordes

Tushar said:
Here's how I would do it. For one application see the 'Overview by
Day' page of the newsgroup stats (http://www.tushar-
mehta.com/excel/ngstats/overview-daily.html)

Suppose the months are in column A and the y-values in column B as in:
1-Jan 6
1-Feb 8
1-Mar 11
1-Apr 10
1-May 13
1-Jun 11
1-Jul 9
1-Aug 16
1-Sep 12
1-Oct 14
1-Nov 12
1-Dec 19
1-Jan 17
1-Feb 21
1-Mar 19
1-Apr 20
1-May 20
1-Jun 24
1-Jul 28
1-Aug 24
1-Sep 21
1-Oct 22
1-Nov 25
1-Dec 25

Then, in column C (C1 specifically) enter the formula
=IF(OR(MONTH(A1)<=3,MONTH(A1)>=11),MAX($B$1:$B$24),NA())

Obviously, you would adjust the above formula for your specific needs.
This one 'shades' Nov.-Mar.
Copy C1 as far down col. C as there is data in column B.

Plot A:C as a column chart. Click the plotted series corresponding to
column B. Select Chart | Chart Type... and change it to a Line chart.

Double-click the plotted series corresponding to col. C. From the
Patterns tab, set the border to none and the area to some light color.
From the Options tab set the Gap Width to zero.

Just a quick question here. Why isn't the logical test required here
an AND rather than OR?

John
 
B

Barb Reinhardt

If you choose>=November (11), you get Nov and Dec.
If you choose <=March (3), you get Jan, Feb, March.

If you select AND, you'll get nothing because there is nothing that is both
=11 and <=3. That would work for dates between June and September,
however.
 
T

Tushar Mehta

Just a quick question here. Why isn't the logical test required here
an AND rather than OR?
Consider any month between Jan (1) and Dec (12). What will be the
result of the test Mth <=3 *and* Mth >=11?

Of course, if one reversed the test, the appropriate connector would be
AND. Hence, by the definition I used, non-Winter months would be
Mth >3 *and* Mth <11

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
J

John Cordes

Tushar said:
Consider any month between Jan (1) and Dec (12). What will be the
result of the test Mth <=3 *and* Mth >=11?

Of course, if one reversed the test, the appropriate connector would be
AND. Hence, by the definition I used, non-Winter months would be
Mth >3 *and* Mth <11
Sorry! Yes, I was using different inequalities, which required the AND,
and didn't look carefully enough at the original interval desired.

My apologies,
John
 
B

Bob Richardson

Nice idea Tushar - I've got the columnar chart looking pretty good. Is there
a way to control the width of the bars (e.g. set them all to "n" pixels
wide) while reducing the space between the columns to "y" pixels?

One more request. Is there a way to draw a horizontal line on the column
chart - to show the median?
 
B

Bob Richardson

Thanks Jon,

I followed you all the way to the last step....then tripped :(

How did you get the average to appear in the secondary y-axis?
Do you take the value from the calculated field (in your little average
table) or did you "cheat" and just type it in the title of the y-axis?

How can you get that label to appear right at the height of the line.

The only way I could get a label there was to type in it, and it's displayed
in the middle of the y-axis, not right at the average.

Bob
 
J

Jon Peltier

Bob -

That label is not on the secondary axis. It is a data label (Show
Values) for the point plotted at the average value along the right edge
of the chart.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
B

Bob Richardson

Got it :) It wasn't obvious to me at first to right click on the little
spot where the average bar crosses the y axis on the right side.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top