increasing pattern density with grid.pattern

2019-08-31 07:14发布

问题:

The grid.pattern function supplied by gridExtra will fill a polygon with diagonal lines. I want to increase the density of lines, i.e., the number of diagonal lines that appears in any given space. Is there an argument that I can pass to grid.pattern that controls the density of lines?

Here's a minimal example:

library(gridExtra)
grid.pattern(pattern = 1)

That code draws a rectangle covered by diagonal lines. How can I change the code so that the rectangle includes (say) twice as many lines? I've read the function documentation and tried changing some arguments to grid.pattern, but nothing has worked.

回答1:

You can use the granularity argument to set the distance between the diagonal lines:

library(gridExtra)
grid.pattern(pattern = 1, granularity = unit(2.5, "mm")) ## (Default is 5 mm)


标签: r graphics