Group Abstract Group Abstract

Message Boards Message Boards

2
|
11.8K Views
|
7 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Fit a curve using dated data formatted for DateListPlot?

Show how to Fit a line or curve to this data (could not find it in Help):

data = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30}, 15}, {{2006, 11, 20}, 20}};      
DateListPlot[data, Joined -> False]

Thank you, Jack Calman

POSTED BY: Jack Calman
7 Replies

There are different ways of doing this. One way would be to create a plot with a green line where you want green and make a plot with a red line where you want red. You can then combine the plots together with Show.

POSTED BY: Sean Clarke

Hi Sean, Thanks for your reply, but the intention is simular as this proposal and seems not to work with the fitPlot line:

Module[{dates, vals1, vals2, data1, data2, data3}, dates = Table[{2012, k, 1}, {k, 12}]; vals1 = {1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1}; vals2 = {4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3}; data1 = Transpose[{dates, vals1}]; data2 = Transpose[{dates, vals2}]; DateListPlot[{data1, data2}, ImageSize -> {150, 93}, Axes -> True, AxesOrigin -> {AbsoluteTime[data1[[1, 1]]], 0}, Filling -> {1 -> {{2}, {Red, Darker[Green]}}}, PlotRange -> Full] // Print;]

Can you help?

Thanks,....Jos

POSTED BY: Jos Klaps
POSTED BY: Jos Klaps

Hi Sean,

See above. Sorry, It shoulld be 'Joined->True' instead of ListLinePlot.

Thanks,....Jos

POSTED BY: Jos Klaps

Thanks Sam. And Sean - very nice indeed! Jack Calman

POSTED BY: Jack Calman
POSTED BY: Sean Clarke

Try first converting from date format to AbsoluteTime - which is not a list but a number. The rest should be easy.

{AbsoluteTime[#1], #2} & @@@ data

{{3368649600, 10}, {3369859200, 12}, {3371155200, 15}, {3372969600, 20}}

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard