hexSticker
hexSticker copied to clipboard
is there a way to add a matrix?
I'd be interested to add a table/matrix (say 4 cols and 3 rows) in the hexSticker.
You probably gave up on this one, but another visitor might have this same question. Here's some help to get you started. Polishing this to include positioning, saving, etc. is left as an exercise for the reader. I tip my hat to @MyKo101 for his nice reprex for his issue (see https://github.com/GuangchuangYu/hexSticker/issues/121). I lifted his reprex for this example because, alas, I am a gangstR ;-)
library(grid)
library(gridExtra)
library(hexSticker)
library(ggplot2)
# create a plain white plot that fills the plot window
p <- ggplot() +
theme_void() +
theme(plot.background=element_rect(fill = "white"))
# create the sticker
s <- sticker(p, package = "cars_table",p_color = "darkgray",
s_x = 1, s_y = 1,s_width = 2, s_height = 2.5, h_color = "black",
white_around_sticker = TRUE)
# plot to see it
plot(s)
# add the table on top
grid.draw(tableGrob(mtcars[1:3, 1:4], rows = NULL))