if (require("grid")) {
x_hex <- 0.5 + 0.5 * cos(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
y_hex <- 0.5 + 0.5 * sin(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
gp <- gpar(col = "black", fill = "lightblue")
# pch 0-6 are simple shapes with no fill
grid.pattern_pch(x_hex, y_hex, shape = 0:6, gp = gp,
spacing = 0.1, density = 0.4, angle = 0)
# pch 7-14 are compound shapes with no fill
grid.newpage()
grid.pattern_pch(x_hex, y_hex, shape = 7:14, gp = gp,
spacing = 0.1, density = 0.4, angle = 0)
# pch 15-20 are filled with 'col'
grid.newpage()
grid.pattern_pch(x_hex, y_hex, shape = 15:20, gp = gp,
spacing = 0.1, density = 0.4, angle = 0)
# pch 21-25 are filled with 'fill'
grid.newpage()
grid.pattern_pch(x_hex, y_hex, shape = 21:25, gp = gp,
spacing = 0.1, density = 0.4, angle = 0)
# using a 'basket' weave `type` with two shapes
grid.newpage()
grid.pattern_pch(x_hex, y_hex, shape = c(1,4), gp = gp,
type = "basket",
spacing = 0.1, density = 0.4, angle = 0)
}
Run the code above in your browser using DataLab