Search notes:

R graphics: adding a grid

The value of a graph might be increased by adding a grid to it.
This can be done using the grid function.
Note: in the following example, grid is first called and points afterwards in order to not overpaint the grid with the points:
x11()

x <- seq(-6, 10, by=0.25) # c(-6:10)
y <- x*x*x/8 - 9*x -15

x11()

plot(
     c(), c(),    # Empty set, points will be drawn later …
     type = "n",  # start new plot, but don't add data
    xlim=c(-8,12)                  ,
    ylim=c(-45,15)                 ,
  )

grid()

# Call points again so that points that were drawn over by grid are
# painted »above« the grid:
points(x, y)

# wait for mouse click or enter pressed:
z <- locator(1)
Github repository about-r, path: /graphics/decoration/grid.R

See also

R graphics

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745519864, '3.129.17.22', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/graphics/decoration/grid(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78