I have a data set which contains three columns: Date with no time stamp, TimeTS of the day converted to number of hours since midnight for a specific event associated with the Date. The third column is the Phase which is either or morning, afternoon, evening or night. Phase is derived from TimeTS.
Below is a sample
Date TimeTS Phase
2020-01-29 2.75 Night
2020-01-29 4.83 Morning
2020-01-29 7 Morning
2020-01-30 10.6 Afternoon
I need to use an interactive charting like plotly to show the following:
- A scatter chart with
Dateon the x-axis andTimeon theywith each instance of time marked across each date - Translucent bands of the
Phaserunning horizontally on the chart for easy interpretation of time bands and the distribution of markers byPhase
The below code gives me close to my desired result but not exactly.
p <- ggplot(clean.data, aes(x=Date,y=TimeTS)) +
geom_rect(data=clean.data, mapping = aes(
xmin=min(Date),
xmax=max(Date),
ymin=0,
ymax=24,
fill=Phase), alpha=0.1) +
# scale_fill_manual(values=c("Morning" = "red", "Afternoon" = "blue", "Evening" = "green", "Night" = "black")) +
geom_point()
p <- ggplotly(p)
p
This gets me only one of the Phase bands on the chart and not others. Plus i think its running vertically and not horizontally.
Any ideas are appreciated.
