烛台图(绘图)R
candlestick chart (plotly) R
我对来自 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))
你没有错过日期结束时的s吗?
df %>%
plot_ly(x = dates, type="candlestick",
open = open, close = close,
high = max, low = min) %>%
layout(title = "Basic Candlestick Chart")
我对来自 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))
你没有错过日期结束时的s吗?
df %>%
plot_ly(x = dates, type="candlestick",
open = open, close = close,
high = max, low = min) %>%
layout(title = "Basic Candlestick Chart")