Highlight (shade) plot background in specific time range

前端 未结 3 1267
栀梦
栀梦 2020-12-01 10:11

On a generic plot, with time on the x-axis, I would like to highlight a period of some specific years.

How can I bestly do this? My idea is for example a light yello

3条回答
  •  [愿得一人]
    2020-12-01 10:39

    You can use the chartSeries() function in quantmod with an xts timeSeries and the addTA() function to add the background highlighting:

    addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333", border=NA)
    

提交回复
热议问题