【发布时间】:2021-12-09 04:24:30
【问题描述】:
我想按城市绘制一条连续线,也就是说我只想连接日期相互跟随的点。
代码:
city = c(rep("paris", 4), rep("lyon", 11), rep("marseille", 10), rep("lille", 5), rep("toulouse", 4), rep("bordeaux", 3))
start = c("2018-08-04", "2018-08-05", "2018-08-06", "2018-08-07", "2018-07-25", "2018-07-26", "2018-07-27", "2018-07-30", "2018-07-31", "2018-08-01", "2018-08-02", "2018-08-03", "2018-08-04", "2018-08-05", "2018-08-06", "2018-07-29", "2018-07-30", "2018-07-31", "2018-08-01", "2018-08-02", "2018-08-03", "2018-08-04", "2018-08-05", "2018-08-06", "2018-08-07", "2018-08-03", "2018-08-04", "2018-08-05", "2018-08-06", "2018-08-07", "2018-08-04", "2018-08-05", "2018-08-06", "2018-08-07", "2018-08-03", "2018-08-04", "2018-08-05")
max = c(rep(36.4, 4), rep(37.2,3), rep(38.4,8), rep(37.4,10), rep(36.7,5), rep(34.9,4), rep(34.8,3))
tab = as.data.frame(city, start, max)
tab$max = as.numeric(tab$max)
tab$start = as.Date(tab$start)
fig <- plot_ly(tab, x = ~start, y = ~max, color = ~city, mode = 'marker')
fig
我在不想连接的地方放了一个十字架
【问题讨论】: