From: jroge on 19 Oct 2009 07:11 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
From: Albert Retey on 20 Oct 2009 04:49 jroge wrote: > 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] > you could do that with ColorFunction, as shown below, which might not be the fastest, but rather clear in what it does: DateListPlot[FinancialData["GE", "Jan. 1, 2008"], Joined -> True, Filling -> Bottom, ColorFunction -> Function[{x, y}, Switch[DateString[x, "Quarter"], "1" | "3", RGBColor[0.5, 0.5, 1], "2" | "4", RGBColor[0.8, 0.8, 0.8]]], ColorFunctionScaling -> False ] hth, albert
From: Armand Tamzarian on 20 Oct 2009 04:49 On Oct 19, 6:11=C2 am, jroge <jr...(a)mac.com> wrote: > 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 I saw a blog post that describes how to do this: http://wildebeests.wordpress.com/2009/08/16/creating-highlighting-bands-in-plots/ Easiest way is to split your data into separate lists for periods you want shaded eg. months, quarters etc. DateListPlot[{month1,month2,month3 ...}, Filling{Filling=E2=86=92{{1=E2=86= =92Bottom}, {1=E2=86=92Top}, {2=E2=86=92Bottom}, {2=E2=86=92Top},=E2=80=A6}] Mike
From: David Park on 20 Oct 2009 04:55 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(a)Blue, Joined -> True] & /@ Join[Q1Iter[2005, 2009], Q3Iter[2005, 2009]], DateListDraw[FinancialData["GE", #], AxesOrigin -> {Automatic, 0}, Filling -> Axis, FillingStyle -> Lighter(a)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(a)comcast.net http://home.comcast.net/~djmpark/ From: jroge [mailto:jroge(a)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
From: Mark McClure on 20 Oct 2009 04:58 On Mon, Oct 19, 2009 at 7:14 AM, jroge <jroge(a)mac.com> wrote: > 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. How's this: date = {2008, 1}; duration = 16; data = Table[FinancialData["GE", {date, date = DatePlus[date, {1, "Month"}]}], {duration}]; data = Append[Append[#[[1]], #[[2, 1]]] & /@ Partition[data, 2, 1], Last[data]]; DateListPlot[data, Joined -> True, Filling -> Table[i -> {Bottom, If[EvenQ[i], RGBColor[1, 0, 0, 0.5], RGBColor[0, 0, 1, 0.5]]}, {i, 1, duration}]] The redefinition of data just makes things line up a little nicer. You can delete that line to see what I mean. Hope that helps, Mark McClure
|
Next
|
Last
Pages: 1 2 Prev: Help needed for exporting graphplot3d to dxf Next: Question on Dynamic with "DockedCell" |