# use the function directly to make a hexagon with the pattern
library(grid)
x <- 0.5 + 0.5 * cos(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
y <- 0.5 + 0.5 * sin(seq(2 * pi / 4, by = 2 * pi / 6, length.out = 6))
grid.newpage()
grid.pattern_geo(params = list(pattern_type = "633", pattern_scale = 4),
boundary_df = data.frame(x, y, id = 1))
if (FALSE) { # require(ggpattern)
# use the function via ggpattern by specifying `pattern = 'geo'`
library(ggplot2)
library(ggpattern)
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col_pattern(aes(color = trt, pattern_type = trt), pattern = 'geo',
pattern_color = "black", fill = "white", pattern_fill = "white") +
scale_pattern_type_manual(values = c("101", "313", "634")) +
scale_color_viridis_d() +
theme(legend.key.size = unit(1.5, 'cm'))
}
Run the code above in your browser using DataLab