I have a multi-line chart created using ggplot2 with autoplot and plotly in R code. I would like to add a single point on each line on the chart. The data frame I am plotting is of class xts. In the toy example below, I would like to add a point at 2019-12-22 on the "aa" line (red) and at 2019-12-24 on the "bb" line (blue). The dates for the points are in a named vector, 'my_points'. How do I do this??
library("xts")
library("ggplot2")
library("plotly")
my_dates <- as.Date(18250:18256)
## My points are in a named vector ...
my_points <- c(my_dates[3], my_dates[5])
names(my_points) <- c("aa", "bb")
## The toy data for the example created as an xts object
my_df <- data.frame(aa = c(14,12,23,14,15,26,17),
bb = c(14.2, 16.0, 12.3, 13.8, 10.1, 9.6, 8.9))
my_xts <- xts(my_df, order.by = my_dates)
## Plotted using autoplot and plotly to make it interactive
p <- autoplot(my_xts, facets = NULL)
pl <- ggplotly(p)
print(pl)