在时间序列图上需要一条固定的水平线
requiring a a fixed horizontal line on a times series plot
我有一个基于时间序列的绘图,但现在我需要添加一个固定的水平线,比如 y=238
你能给我一些想法吗?
fig= plot_ly(
data = x,
x = x$time,
y = x$infected,
mode = 'lines'
)
fig
尝试
fig
abline(h=238, col='red', lw=2)
用这个的最后一行弄明白了
fig <- plot_ly() %>%
add_lines(x = ~netA$time, y = ~netA$infected, name = "Infection A", type = "scatter", mode = "lines") %>%
add_lines(x = ~netB$time, y = ~netB$infected, name = "Infection B", type = "scatter", mode = "lines") %>%
add_segments(x = 0, xend = nrow(netA), y = vcount(g_primschool_a), yend = vcount(g_primschool_a))
fig
我有一个基于时间序列的绘图,但现在我需要添加一个固定的水平线,比如 y=238 你能给我一些想法吗?
fig= plot_ly(
data = x,
x = x$time,
y = x$infected,
mode = 'lines'
)
fig
尝试
fig
abline(h=238, col='red', lw=2)
用这个的最后一行弄明白了
fig <- plot_ly() %>%
add_lines(x = ~netA$time, y = ~netA$infected, name = "Infection A", type = "scatter", mode = "lines") %>%
add_lines(x = ~netB$time, y = ~netB$infected, name = "Infection B", type = "scatter", mode = "lines") %>%
add_segments(x = 0, xend = nrow(netA), y = vcount(g_primschool_a), yend = vcount(g_primschool_a))
fig