[英]R Plotly - messed line chart
我想以繪圖方式繪制時間序列。 數據框有兩列,即日期格式的日期和作為整數的符號數,例如:
order_created margin
2017-01-01 7004
2017-02-01 4424
2017-03-01 3792
2017-04-01 6031
2017-05-01 7561
2017-06-01 6903
2017-07-01 6687
2017-08-01 3283
2017-09-01 6683
2017-10-01 4781
2017-11-01 6960
當我使用type =“ scatter”&fill ='tozeroy'繪制數據時,我會感到完全混亂:
plot_ly(somedata,
x = ~order_created,
y = ~margin,
name = 'Total margin',
type = 'scatter',
mode = 'none',
fill = 'tozeroy')
當我使用相同的數據和代碼,但將類型更改為“ bar”時,它將創建正確的圖:
plot_ly(somedata,
x = ~order_created,
y = ~margin,
name = 'Total margin',
type = 'bar',
mode = 'none',
fill = 'tozeroy')
有什么建議如何制作適當的折線圖(填充區域)?
謝謝
在plotly 4.7.1
,這對我來說很好:
# reproducible example!
somedata <- read.table(text=
"order_created margin
2017-01-01 7004
2017-02-01 4424
2017-03-01 3792
2017-04-01 6031
2017-05-01 7561
2017-06-01 6903
2017-07-01 6687
2017-08-01 3283
2017-09-01 6683
2017-10-01 4781
2017-11-01 6960", header=TRUE,
colClasses = c('Date','numeric'))
library(plotly)
(p <- plot_ly(somedata,
x = ~order_created,
y = ~margin,
name = 'Total margin',
type = 'scatter',
mode = 'none',
fill = 'tozeroy'))
plotly_IMAGE(p, format = "png", out_file = "output.png")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.