plotly::subplot not showing geom_vline

Viewed 24

I have a chart with visible geom_vlines. this works well in ggplot:

hits  <- which(dat$meanpos >= 0.7 & dat$relative_positive_diff >= 0.7)
hittimes <- dat$time[hits]

p2 <- ggplot(data = dat, aes(x = time))+
  geom_line(aes(y = meanpos, color='meanpos'))+
  geom_vline(xintercept = hittimes, size = 3)+
  scale_x_datetime(breaks = scales::date_breaks('15 secs'), date_labels = "%H:%M:%S")+
  scale_color_manual(values=c('meanpos' = 'blue'))+
  theme(legend.position = "top")
p2

enter image description here

But for some esoteric reason, plotly::subplot just gets rid of my geom_vlines. Any idea why?

subshared <- plotly::subplot(list(p2, p2), nrows = 2, shareX=T)

enter image description here

data:

dat <- structure(list(time = structure(c(1663596208.413, 1663596208.52, 
1663596209.091, 1663596209.501, 1663596210.028, 1663596210.165, 
1663596212.084, 1663596212.352, 1663596212.84, 1663596213.035, 
1663596213.396, 1663596213.823, 1663596214.484, 1663596214.652, 
1663596215.447, 1663596216.637, 1663596218.201, 1663596219.115, 
1663596220.021, 1663596223.201), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), bid = c(11758.68, 11758.8, 11758.93, 11759.05, 
11759.18, 11758.93, 11758.8, 11759.18, 11759.05, 11759.18, 11759.3, 
11760.05, 11759.93, 11760.05, 11759.43, 11759.3, 11759.43, 11759.55, 
11759.68, 11759.93), ask = c(11760.58, 11760.7, 11760.83, 11760.95, 
11761.08, 11760.83, 11760.7, 11761.08, 11760.95, 11761.08, 11761.2, 
11761.95, 11761.83, 11761.95, 11761.33, 11761.2, 11761.33, 11761.45, 
11761.58, 11761.83), flags = c(6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 
6, 6, 6, 6, 6, 6, 6, 6, 6, 6), typical = c(11759.63, 11759.75, 
11759.88, 11760, 11760.13, 11759.88, 11759.75, 11760.13, 11760, 
11760.13, 11760.25, 11761, 11760.88, 11761, 11760.38, 11760.25, 
11760.38, 11760.5, 11760.63, 11760.88), row = 216:235, prevrow_short = c(213L, 
214L, 214L, 214L, 214L, 214L, 217L, 218L, 219L, 220L, 221L, 221L, 
221L, 221L, 223L, 226L, 229L, 230L, 231L, 234L), windsize = c(4, 
4, 5, 6, 7, 8, 6, 6, 6, 6, 6, 7, 8, 9, 8, 6, 4, 4, 4, 2), diff = c(-0.25, 
0.119999999998981, 0.130000000001019, 0.119999999998981, 0.130000000001019, 
-0.25, -0.130000000001019, 0.380000000001019, -0.130000000001019, 
0.130000000001019, 0.119999999998981, 0.75, -0.119999999998981, 
0.119999999998981, -0.619999999998981, -0.130000000001019, 0.130000000001019, 
0.119999999998981, 0.130000000001019, 0.25), absdiff = c(0.25, 
0.119999999998981, 0.130000000001019, 0.119999999998981, 0.130000000001019, 
0.25, 0.130000000001019, 0.380000000001019, 0.130000000001019, 
0.130000000001019, 0.119999999998981, 0.75, 0.119999999998981, 
0.119999999998981, 0.619999999998981, 0.130000000001019, 0.130000000001019, 
0.119999999998981, 0.130000000001019, 0.25), sumabsdiff = c(0.630000000001019, 
0.619999999998981, 0.75, 0.869999999998981, 1, 1.25, 0.880000000001019, 
1.14000000000306, 1.14000000000306, 1.15000000000509, 1.14000000000306, 
1.89000000000306, 2.01000000000204, 2.13000000000102, 2.36999999999898, 
1.85999999999694, 1, 1, 0.510000000002037, 0.380000000001019), 
    positive = c(FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, 
    TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, 
    TRUE, TRUE, TRUE, TRUE), meanpos = c(0.75, 0.75, 0.8, 0.833333333333333, 
    0.857142857142857, 0.75, 0.666666666666667, 0.666666666666667, 
    0.5, 0.5, 0.5, 0.571428571428571, 0.5, 0.555555555555556, 
    0.625, 0.5, 0.5, 0.5, 0.75, 1), posdiff = c(0, 0.119999999998981, 
    0.130000000001019, 0.119999999998981, 0.130000000001019, 
    0, 0, 0.380000000001019, 0, 0.130000000001019, 0.119999999998981, 
    0.75, 0, 0.119999999998981, 0, 0, 0.130000000001019, 0.119999999998981, 
    0.130000000001019, 0.25), negdiff = c(0.25, 0, 0, 0, 0, 0.25, 
    0.130000000001019, 0, 0.130000000001019, 0, 0, 0, 0.119999999998981, 
    0, 0.619999999998981, 0.130000000001019, 0, 0, 0, 0), sumposdiff_short = c(0.380000000001019, 
    0.369999999998981, 0.5, 0.619999999998981, 0.75, 0.75, 0.5, 
    0.760000000002037, 0.630000000001019, 0.640000000003056, 
    0.630000000001019, 1.38000000000102, 1.38000000000102, 1.5, 
    1.5, 0.989999999997963, 0.25, 0.25, 0.380000000001019, 0.380000000001019
    ), sumnegdiff_short = c(0.25, 0.25, 0.25, 0.25, 0.25, 0.5, 
    0.380000000001019, 0.380000000001019, 0.510000000002037, 
    0.510000000002037, 0.510000000002037, 0.510000000002037, 
    0.630000000001019, 0.630000000001019, 0.869999999998981, 
    0.869999999998981, 0.75, 0.75, 0.130000000001019, 0), relative_positive_diff = c(0.603174603175245, 
    0.596774193547725, 0.666666666666667, 0.712643678160583, 
    0.75, 0.6, 0.568181818181161, 0.666666666666667, 0.552631578946781, 
    0.556521739130627, 0.552631578946781, 0.730158730158089, 
    0.686567164178915, 0.704225352112339, 0.632911392405335, 
    0.532258064515908, 0.25, 0.25, 0.745098039214707, 1), market_open = c(FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE), timediff = c(0.751000165939331, 0.10699987411499, 
    0.571000099182129, 0.409999847412109, 0.527000188827515, 
    0.136999845504761, 1.91900014877319, 0.267999887466431, 0.48799991607666, 
    0.195000171661377, 0.360999822616577, 0.427000045776367, 
    0.66100001335144, 0.167999982833862, 0.795000076293945, 1.19000005722046, 
    1.56399989128113, 0.914000034332275, 0.905999898910522, 3.1800000667572
    ), avgspeed = c(1.05401842413301, 1.06354695220097, 1.15420128813177, 
    1.26528894376796, 1.32852532341034, 1.47983724557824, 1.63443203316947, 
    1.56576199716125, 1.60042685131335, 1.6977927932152, 1.78147279405284, 
    1.8445323581144, 1.79533219638629, 1.94636685185528, 2.37882848636314, 
    1.66574125574046, 1.07613666714816, 0.896258110465208, 0.874508111809247, 
    0.489476264514154)), pandas.index = <environment>, row.names = 216:235, class = "data.frame")

0 Answers
Related