Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there a way to add a matrix? #107

Open
complexgenome opened this issue Sep 1, 2020 · 1 comment
Open

is there a way to add a matrix? #107

complexgenome opened this issue Sep 1, 2020 · 1 comment

Comments

@complexgenome
Copy link

I'd be interested to add a table/matrix (say 4 cols and 3 rows) in the hexSticker.

@gangstR
Copy link

gangstR commented Jan 30, 2021

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 #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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants