【问题标题】:R xts object plot separate axisR xts 对象绘制单独的轴
【发布时间】:2017-03-27 13:27:56
【问题描述】:

例子:

library(xts)
data(sample_matrix)
matrix_xts <- as.xts(sample_matrix, dateFormat='Date')
matrix_xts[,1] = matrix_xts[,1] * 100
plot(matrix_xts)

如果我绘制它,将很难可视化数据。是否有可能以某种方式将第一列绘制在 xts.plot 的辅助 y 轴上?

【问题讨论】:

    标签: r plot xts


    【解决方案1】:

    据我所知,xts 绘图不支持此功能。 (此外,出于各种原因,有些人不赞成在一个绘图上使用 2 个不同的轴进行绘图,例如这可能会被视为具有误导性。)

    这是一种解决方法。在不同的图上绘制不同比例的列:

    # Get latest version of xts for nice new plot tools (>= 0.10 not yet on CRAN)
    library(devtools)
    install_github("joshuaulrich/xts")
    plot(matrix_xts[, 2:4])
    lines(matrix_xts[,1], on = NA)
    

    ?plot.xts for xts version >=0.10 有一些有用的示例,用于与颜色等绘图相关的选项。

    【讨论】:

      猜你喜欢
      • 2012-11-22
      • 2018-10-07
      • 1970-01-01
      • 2017-12-08
      • 2020-04-17
      • 2018-06-08
      • 1970-01-01
      • 2018-02-20
      • 2012-08-05
      相关资源
      最近更新 更多