Shading Time Series plots

Very new to plotly (day 1). I have a time series plot in ggplot2 where there is shading for periods of recession. A background appears pink when there is a recession and unshaded when there isn’t one.

Here’s an example of coding it in ggplot.

For what it’s worth, I tried the ggplotly function to create the plotly chart, but the shading was lost. I am using R. Can this sort of shading be added to a time series? Thanks.

@rmacey, it is possible to add that sort of shading using shapes. Here is an example https://plot.ly/r/shapes/#rectangles. You will have to modify that example slightly if you want the shaded regions to extend the entire height of the plot. You can do that by setting yref='paper' and then y0=0, y1=1.

1 Like