如何在plot.xts中删除网格线

时间:2018-08-18 10:44:12

标签: r plot xts

我正在使用xts绘制plot.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)

1 个答案:

答案 0 :(得分:2)

您对指定的图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)

With and Without gridlines