【问题标题】:Formatting axis in Surface plot Plotly R在曲面图中格式化轴 Plotly R
【发布时间】:2016-10-14 04:44:40
【问题描述】:

为天然气价格绘制 3 个月曲线。我有一些轴问题。我希望能够显示日期而不是天数。

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")))

【问题讨论】:

    标签: r time-series axis plotly


    【解决方案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")))
    

    【讨论】:

    • 太好了 - 我如何调整日期文本的角度?
    • 非常感谢 - 知道我如何在 x 轴上反转轴标签吗?最后一个对不起
    • 我们通常会添加 autorange = "reversed" ,但它看起来不适用于 3D 绘图
    猜你喜欢
    • 2021-02-23
    • 2018-05-06
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多