簡體   English   中英

Plotly 3D 表面 plot 中的 ZE1E1D3D40573127E9ZEE0480CAF12836D 數據

[英]Plotly 3D surface plot in R time for series data

有沒有什么方法可以使用 plotly 在 R 中繪制 3D 表面作為時間序列。 我已經嘗試了幾種方法,但無法獲得有意義的表示。

這是我的數據的樣子:

                0.25       0.5      0.75         1         2          3          4          5          7         10
1991-01-02 0.1099018 0.1075803 0.1060026 0.1048713 0.1026496 0.10156800 0.10040423 0.09918249 0.09782469 0.09941434
1991-01-03 0.1107301 0.1069789 0.1049246 0.1035827 0.1013430 0.10060837 0.09977042 0.09876087 0.09755911 0.09913463
1991-01-04 0.1096955 0.1057843 0.1037788 0.1025263 0.1005516 0.09989326 0.09913758 0.09828665 0.09744314 0.09923485
1991-01-07 0.1081831 0.1055844 0.1041088 0.1031551 0.1016053 0.10098120 0.10020332 0.09935368 0.09857824 0.10051402
1991-01-08 0.1070853 0.1046270 0.1035221 0.1028750 0.1018182 0.10118515 0.10035681 0.09950923 0.09881024 0.10080843
1991-01-09 0.1067455 0.1040249 0.1028210 0.1021501 0.1013992 0.10130785 0.10093757 0.10034346 0.09963237 0.10130524
                  15         20        25        30
1991-01-02 0.1013165 0.09823009 0.1002991 0.1150025
1991-01-03 0.1007016 0.09737618 0.0996668 0.1147670
1991-01-04 0.1015744 0.09906617 0.1009025 0.1154665
1991-01-07 0.1032524 0.10086460 0.1024462 0.1175229
1991-01-08 0.1036377 0.10126557 0.1027223 0.1177263
1991-01-09 0.1043398 0.10207753 0.1032627 0.1183408

這是迄今為止我能得到的最接近的:

plot_ly(z = ~as.matrix(mdf)) %>%
  add_surface()

在此處輸入圖像描述

如您所見,它完全忽略了所需的xy軸。 任何幫助將不勝感激!

如果您希望 plot 考慮行名和列名,則需要將它們作為 arguments 傳遞(見下文)。

PS:下次請使用dput(head(mdf))共享您的數據。

library(plotly)

mdf <- structure(list(`0.25` = c(0.1099018, 0.1107301, 0.1096955, 0.1081831,
0.1070853, 0.1067455), `0.5` = c(0.1075803, 0.1069789, 0.1057843, 0.1055844,
0.104627, 0.1040249), `0.75` = c(0.1060026, 0.1049246, 0.1037788, 0.1041088,
0.1035221, 0.102821), `1` = c(0.1048713, 0.1035827, 0.1025263, 0.1031551,
0.102875, 0.1021501), `2` = c(0.1026496, 0.101343, 0.1005516, 0.1016053,
0.1018182, 0.1013992), `3` = c(0.101568, 0.10060837, 0.09989326, 0.1009812,
0.10118515, 0.10130785), `4` = c(0.10040423, 0.09977042, 0.09913758,
0.10020332, 0.10035681, 0.10093757), `5` = c(0.09918249, 0.09876087,
0.09828665, 0.09935368, 0.09950923, 0.10034346), `7` = c(0.09782469,
0.09755911, 0.09744314, 0.09857824, 0.09881024, 0.09963237), `10` =
c(0.09941434, 0.09913463, 0.09923485, 0.10051402, 0.10080843, 0.10130524 ),
`15` = c(0.1013165, 0.1007016, 0.1015744, 0.1032524, 0.1036377, 0.1043398),
`20` = c(0.09823009, 0.09737618, 0.09906617, 0.1008646, 0.10126557,
0.10207753), `25` = c(0.1002991, 0.0996668, 0.1009025, 0.1024462, 0.1027223,
0.1032627), `30` = c(0.1150025, 0.114767, 0.1154665, 0.1175229, 0.1177263,
0.1183408)), class = "data.frame", row.names = c("1991-01-02", "1991-01-03",
"1991-01-04", "1991-01-07", "1991-01-08", "1991-01-09" ))

plot_ly(
  z = ~ as.matrix(mdf),
  x = ~ as.Date(rownames(mdf)),
  y = ~ as.numeric(colnames(mdf)),
  type = "surface",
  colorbar = list(title = "My surface plot")
) %>% layout(scene = list(
  xaxis = list(title = "X-Axis"),
  yaxis = list(title = "Y-Axis"),
  zaxis = list(title = "Z-Axis")
))

結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM