【问题标题】:How to remove grid lines in plot.xts如何删除 plot.xts 中的网格线
【发布时间】:2019-01-25 05:24:32
【问题描述】:

我正在使用plot.xts() 绘制xts 对象,但我找不到删除网格线的参数,例如grid = FALSE 或其他东西。有没有其他方法可以摆脱那些灰线?这是R文档中plot.xts()的用法。

# S3 method for xts
plot(x, y = NULL, ..., subset = "",
  panels = NULL, multi.panel = FALSE, col = 1:8, up.col = "green",
  dn.col = "red", bg = "#FFFFFF", type = "l", lty = 1, lwd = 2, lend = 1,
  main = deparse(substitute(x)), observation.based = FALSE,
  ylim = NULL, yaxis.same = TRUE, yaxis.left = TRUE, yaxis.right = TRUE,
  major.ticks = "months", minor.ticks = NULL,
  grid.ticks.on = "months", grid.ticks.lwd = 1, grid.ticks.lty = 1,
  grid.col = "darkgray", labels.col = "#333333", format.labels = TRUE,
  grid2 = "#F5F5F5", legend.loc = NULL)

【问题讨论】:

    标签: r plot xts


    【解决方案1】:

    您对 plot 的调用指定了grid.col = "darkgray",因此您会得到深灰色的网格线。要关闭它们,只需将其更改为 grid.col = NA 。这是一个基于帮助页面?plot.xts中给出的示例的简单示例

    library(xts)
    data(sample_matrix)
    sample.xts <- as.xts(sample_matrix)
    
    par(mfrow=c(1,2))
    plot(sample.xts[,"Close"], main="")
    plot(sample.xts[,"Close"], main="", grid.col = NA)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 1970-01-01
      • 2013-01-06
      • 2014-02-21
      • 2016-07-14
      相关资源
      最近更新 更多