-
Notifications
You must be signed in to change notification settings - Fork 636
Closed
Description
I'm running into an issue plotting a line chart for multiple series when one of the underlying data series includes NA. The code below generates a chart with the complete series being truncated to match the incomplete series. Although you can't see it from the picture, moving the mouse along the front part of the chart shows values, almost as if the line is there but the color is translucent.
dts = seq(from = as.Date("2016-01-01"), to = Sys.Date(), by = "day")
DT = rbind(data.table(Date = dts, Group = "A", Value = rnorm(length(dts))),
data.table(Date = dts, Group = "B",
Value = c(rep(NA, length(dts) / 2), rnorm(length(dts) / 2))))
plot_ly(DT[order(Date, Group)]) %>%
add_lines(x = ~Date, y = ~Value, color = ~Group)
I think the problem has to do with the data order, as the update below results in the expected output.
plot_ly(DT) %>%
add_lines(x = ~Date, y = ~Value, color = ~Group)
In my case, it appears I can get around this issue by sorting my dataset before plotting (stack the series instead of co-mingle the data).
Metadata
Metadata
Assignees
Labels
No labels

