This question uses 'ggpmisc' version 0.3.4 or earlier, see answer below for version 0.3.5 or later.
I like the newish geom_table_npc
in ggpmisc which provides a simple way to add a table to a ggplot and works particularly well with transformed x-axis where trying to set location can be frustrating if plotting bounds may change.
I'm wondering if its possible to change the table theme? I can change the text size using size = 1.8
but then the padding of the cells looks strange which is what I'd like to change. May also want to change the colour.
I think it is using gridExtra::ttheme_default
so I tried setting this in case it gets passed through in the ...
but it just ignores it.
library(ggplot2)
library(ggpmisc)
library(gridExtra)
testdat <- data.frame(x = 1/2:50, y = 50:2)
annotatedf <- data.frame(cat = letters[1:3], val = 1:3)
t1plt <- ggplot(testdat, aes(x = x, y = y)) +
geom_point() +
scale_x_log10()
t1plt +
geom_table_npc(data = annotatedf,
label = list(annotatedf),
npcx = 0.05, npcy = 0.95)
t1plt +
geom_table_npc(data = annotatedf,
label = list(annotatedf),
npcx = 0.05, npcy = 0.95, size = 1.8)
t1plt +
geom_table_npc(data = annotatedf,
label = list(annotatedf),
npcx = 0.05, npcy = 0.95, size = 1.8,
theme = ttheme_default(padding = unit(c(1, 1), "mm")))
#> Warning: Ignoring unknown parameters: theme
Created on 2020-02-18 by the reprex package (v0.3.0)