Message Boards Message Boards

0
|
1470 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

How to shade a portion of a DateListPlot?

Posted 1 year ago

I have a databin of heart rates that I can use with DateListPlot. Now, say I want to highlight a specific time range in the plot (12 noon to 1 PM) by shading the area of the plot from 12 noon to 1 PM.

Question is, how do I do that shading?

DateListPlot[Databin["xxxxxxxxx", {Yesterday, Today}], 
 "PlotTheme" -> "Detailed", "ImageSize" -> "Large"]
POSTED BY: Steven Buehler

Hi Steven,

Here is one way

data = {
{DateObject[{2016, 10, 1}, "Day", "Gregorian", -5.`], 10},
{DateObject[{2016, 10, 15}, "Day", "Gregorian", -5.`], 17}, 
{DateObject[{2016, 10, 30}, "Day", "Gregorian", -5.`], 15}, 
{DateObject[{2016, 11, 20}, "Day", "Gregorian", -5.`], 20}}

(* Change the bounds of the rectangle to span the area of interest to you *)
epilog = {Opacity@.2, Green, 
  Rectangle[{DateObject[{2016, 10, 17}], 0}, {DateObject[{2016, 10, 31}], 25}]};

DateListPlot[data, Epilog -> epilog]

enter image description here

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

Group Abstract Group Abstract