[R] Can grid lines color in a plot be specified?
Marc Schwartz
MSchwartz at MedAnalytics.com
Fri Oct 1 15:15:59 CEST 2004
On Fri, 2004-10-01 at 07:44, Luis Rideau Cruz wrote:
> R-help
>
> Is there any way to specify the color of grid lines in a simple plot?
>
> par(color.tick.marks=c("grey"))
> plot(rnorm(10),tck=1)
>
>
> Thank you
This is one approach:
plot(rnorm(10))
# Now draw both axes
axis(1, tck = 1, col = "grey", lty = "dotted")
axis(2, tck = 1, col = "grey", lty = "dotted")
# Replace the grey plot region border lines with black
box()
In this case, the grid lines are being drawn after the data is plotted,
so it is possible that the lines may overwrite your symbols or other
important visual information. An alternative would be to create the plot
background first, including the grid lines, then add the data with
lines() or points() or other functions. For example:
x <- rnorm(10)
plot(x, type = "n")
axis(1, tck = 1, col = "grey", lty = "dotted")
axis(2, tck = 1, col = "grey", lty = "dotted")
box()
points(x, pch = 19)
HTH,
Marc Schwartz
More information about the R-help
mailing list