Several functions in R's base graphical system, including rect()
and polygon()
, support cross-hatching via their angle=
and density=
arguments:
x = c(0, 0.5, 1, 0.5)
y = c(0.5, 1, 0.5, 0)
par(mar=c(0,0,0,0))
plot.new()
polygon(x, y, angle=45, density=10)
How might I apply similar cross-hatching to a polygon drawn by the grid graphical system's grid.polygon()
function:
library(grid)
grid.newpage()
grid.polygon(x,y)
I've looked in the documentation for ?grid.polygon
and ?gpar
, and have skimmed through Paul Murrel's book on R graphics, and have so far come up empty. Am I missing something obvious? If not, is there some simple hack which will make this possible?
grid.patternFill
) – baptistegridExtra::rpatternGrob
might be helpful if I go in that direction. – Josh O'Brien