0

我对来自 的烛台图有疑问plotly。在我的测试数据上工作正常,但如果我使用我的数据框结果是:

library(plotly)
df %>%
  plot_ly(x = date, type="candlestick",
          open = open, close = close,
          high = max, low = min) %>%
  layout(title = "Basic Candlestick Chart")

问题

> dput(myData)
structure(list(date = structure(c(14978, 14979, 14980, 14981, 
14983, 14984, 14985, 14986, 14987, 14988, 14990, 14991, 14992, 
14993, 14994, 14995, 14997, 14998, 14999, 15000, 15001, 15002, 
15004, 15005), class = "Date"), open = c(2.95, 2.55, 2.95, 2.55, 
2.95, 2.95, 3.24, 5.91, 5.79, 2.55, 2.95, 2.95, 2.95, 2.95, 2.95, 
2.55, 2.55, 5.79, 6.63, 2.55, 2.95, 2.95, 2.55, 5.79), close = c(2.95, 
2.95, 2.55, 2.95, 2.95, 2.95, 2.95, 2.95, 5.79, 2.95, 2.95, 2.95, 
2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 5.79, 2.95, 
2.95), max = c(5.91, 2.95, 2.95, 2.95, 2.95, 2.95, 3.24, 5.91, 
5.79, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 6.63, 2.95, 5.79, 6.63, 
5.79, 2.95, 5.79, 2.95, 6.63), min = c(2.55, 2.55, 2.55, 2.55, 
2.55, 2.95, 2.55, 2.55, 2.95, 2.55, 2.95, 2.55, 2.95, 2.55, 2.95, 
2.55, 2.55, 2.95, 2.55, 2.55, 2.55, 2.55, 2.55, 2.95)), class = c("tbl_df", 
"tbl", "data.frame"), .Names = c("date", "open", "close", "max", 
"min"), row.names = c(NA, -24L))
4

1 回答 1

1

你没有错过日期末尾的s吗?

df %>%
  plot_ly(x = dates, type="candlestick",
      open = open, close = close,
      high = max, low = min) %>%
  layout(title = "Basic Candlestick Chart")
于 2018-01-30T14:57:43.473 回答