[R] how to remove grid lines from coplot graphs

Peter Ehlers ehlers at ucalgary.ca
Wed Dec 1 14:34:46 CET 2010

On 2010-12-01 01:51, Seth Roberts wrote:
> coplot() usually puts grid lines in the panels it makes. To see examples,
> example(coplot).
> How can I remove those grid lines?
 > Seth Roberts

That's hard-coded in coplot. But you can easily make a
modified copy of coplot. Here are the steps:

1. make a copy of coplot; call it mycoplot.
2. add this to the argument list of the function:

    col.grid = "lightgray"

3. find this line in the code:

    grid(lty = "solid")

and change it to

    grid(lty = "solid", col = col.grid)

4. source() your new function.

It wouldn't be a bad idea to also do

    environment(mycoplot) <- environment(coplot)

Now just set col.grid = "transparent"
(or col.grid = 0 should also work) when you
want to suppress the grid. This also gives you
the option of using other grid colours.

Peter Ehlers

More information about the R-help mailing list