Grid in an R plot

后端 未结 4 1130
借酒劲吻你
借酒劲吻你 2020-12-08 06:47

Is there a command to easily add a grid onto an R plot?

4条回答
  •  一整个雨季
    2020-12-08 07:36

    See help(grid) which works with standard graphics -- short example:

    R> set.seed(42)
    R> plot(cumsum(rnorm(100)), type='l')
    R> grid()
    

    The ggplot2 package defaults to showing grids due to its 'Grammar of Graphics' philosophy. And lattice has a function panel.grid() you can use in custom panel functions.

    By the way, there are search functions for help as e.g. help.search("something") and there is an entire package called sos to make R web searches more fruitful.

提交回复
热议问题