2016-06-13 5 views
0

천연 가스 가격에 대해 3 개월 곡선을 만듭니다. 축 문제가 생겼어. 며칠이 아닌 날짜가 표시되도록하고 싶습니다.표면 플롯에서 축 서식 지정하기 Plotly R

library(ggplot2) 
library(Quandl) 
library(magrittr) 
require(plotly) 

#Get first 3 month on the nat gas curve data from Quandl 
my_start_date <- "2013-01-05" 

gas1<-Quandl("CHRIS/CME_NG1", start_date = my_start_date, type = "xts") 
gas2<-Quandl("CHRIS/CME_NG2", start_date = my_start_date, type = "xts") 
gas3<-Quandl("CHRIS/CME_NG3", start_date = my_start_date, type = "xts") 

#isolate the last prices 
gas1a<-gas1[,"Last"] 
gas2a<-gas2[,"Last"] 
gas3a<-gas3[,"Last"] 

p <- merge(as.zoo(gas1a), as.zoo(gas2a), as.zoo(gas3a), all = FALSE) 

#3d graph 
plot_ly(z = p, type = "surface")%>% 
    layout(title = "3 month Nat Gas curve", 
     scene = list(
      xaxis = list(title = "Month"), 
      yaxis = list(title = "Days"), 
      zaxis = list(title = "Price"))) 

답변

1

찾고 계십니까?

plot_ly(y=index(p), z = p, type = "surface")%>% 
    layout(title = "3 month Nat Gas curve", 
     scene = list(
      xaxis = list(title = "Month"), 
      yaxis = list(title = "Days", tickangle = 180), 
      zaxis = list(title = "Price"))) 
+0

내가 날짜의 텍스트를 어떻게 장식합니까? – Rhodo

+0

내 대답을 업데이트했습니다 :-) – MLavoie

+0

x 축에서 축 레이블을 어떻게 바꿀 수 있습니까? 마지막 하나 죄송합니다 – Rhodo