Re: Multi-Colored Filling in DateListPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg104124] Re: Multi-Colored Filling in DateListPlot
- From: "David Park" <djmpark at comcast.net>
- Date: Tue, 20 Oct 2009 04:51:54 -0400 (EDT)
- References: <20214052.1255951567803.JavaMail.root@n11>
One way to do this is with the Presentations package.
Needs["Presentations`Master`"]
Write routines to generate DateListPlot date iterators for each quarter over
a span of years.
Q1Iter[year1_, year2_] :=
Table[{"Jan 1, " <> ToString[year],
"Mar 31, " <> ToString[year]}, {year, year1, year2}]
Q2Iter[year1_, year2_] :=
Table[{"Apr 1, " <> ToString[year],
"Jun 30, " <> ToString[year]}, {year, year1, year2}]
Q3Iter[year1_, year2_] :=
Table[{"Jul 1, " <> ToString[year],
"Sep 30, " <> ToString[year]}, {year, year1, year2}]
Q4Iter[year1_, year2_] :=
Table[{"Oct 1, " <> ToString[year],
"Dec 31, " <> ToString[year]}, {year, year1, year2}]
Then just draw the quarters with their separate filling color. Use
CustomDateTicks to label the time axis.
dateticks =
CustomDateTicks[{{2005, 1, 1}, {2010, 1, 1}, {1, "Year"}, 4},
DateString[#, {"Year"}] &];
Draw2D[
{DateListDraw[FinancialData["GE", #],
AxesOrigin -> {Automatic, 0},
Filling -> Axis,
FillingStyle -> Lighter@Blue,
Joined -> True] & /@ Join[Q1Iter[2005, 2009], Q3Iter[2005, 2009]],
DateListDraw[FinancialData["GE", #],
AxesOrigin -> {Automatic, 0},
Filling -> Axis,
FillingStyle -> Lighter@Red,
Joined -> True] & /@ Join[Q2Iter[2005, 2009], Q4Iter[2005, 2008]]
},
AspectRatio -> .3,
Frame -> True,
FrameTicks -> {{Automatic, Automatic}, {dateticks,
dateticks // NoTickLabels}},
PlotLabel -> Style["GE Stock Price", 14, Bold],
ImageSize -> 500]
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
From: jroge [mailto:jroge at mac.com]
I am working on developing some financial reports and I have gotten
stuck on using multiple colors in the filling of a DateListPlot. I
would like to have the color of the filling alternate between blue and
pink each quarter (or year depending on the plot) rather than a single
color in the entire filling. Here is an example of what I am trying to
do:
http://online.wsj.com/article/SB125479559237566623.html
I suspect that FillingStyle is the function I need to use, but calling
out each quarter's (or year's) data is beyond me. Any thoughts? I have
been using a fairly generic plot of GE stock data for exploration:
DateListPlot[FinancialData["GE", "Jan. 1, 2008"], Joined -> True,
Filling -> Bottom]
Thanks,
Jroge