1
$\begingroup$

How do I draw specific filled regions in DateListPlot? I trying to plot something like this:

enter image description here

Thanks

$\endgroup$
  • $\begingroup$ related: 37460 $\endgroup$ – Kuba Mar 1 '15 at 22:33
3
$\begingroup$

One approach is to use Inset.

DateListPlot[{1, 1, 2, 3, 5, 8, 11}, {2000, 8}, Prolog -> Inset[Graphics[{GrayLevel[.6], 
  Rectangle[Scaled[{.5, .1}], Scaled[{.7, .3}]], 
  Rectangle[Scaled[{.7, .3}], Scaled[{.9, .5}]], 
  Rectangle[Scaled[{.9, .5}], Scaled[{1.1, .7}]]}]]]

enter image description here

Some experimentation may be necessary to place multiple shaded areas in their desired locations.

$\endgroup$
1
$\begingroup$

Using @bbgodfrey's example

list = {1, 1, 2, 3, 5, 8, 11};
pnts = Thread[{AbsoluteTime /@ ({2000, #} & /@ Range[8, 14])[[3 ;; 6]], list[[3 ;; 6]]}];

DynamicModule[{pts = pnts}, LocatorPane[Dynamic[pts], DateListPlot[{1, 1, 2, 3, 5, 8, 11},
 {2000, 8}, Epilog -> {Opacity[.5, Gray], Dynamic[Rectangle @@@ Partition[pts, 2, 1]]},
 Joined -> True], Appearance -> None]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.