Roy
Roy

Reputation: 603

How to remove grid lines in plot.xts

I am plotting an xts object using plot.xts(), but I cannot find an argument to remove the grid lines, like grid = FALSE or something else. Is there any other way to get rid of those grey lines? Here is the usage of plot.xts() from R document.

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

Upvotes: 3

Views: 3767

Answers (1)

G5W
G5W

Reputation: 37641

Your call to plot specified grid.col = "darkgray" so you get dark gray grid lines. To turn them off, simply change that to grid.col = NA . Here is a simple example based on the examples given in the help page ?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

Upvotes: 4

Related Questions