0

With the plot_xtab() function from sjPlot package I can plot percentages of gear inside of every cyl as stacked bar plots:

library(sjPlot)

plot_xtab(
  x = mtcars$gear,
  grp = mtcars$cyl,
  margin = "row",
  bar.pos = "stack",
  show.summary = TRUE,
  coord.flip = TRUE
)

How can I increase the font size within the plots inside sjPlot package?

I know that I can make this plot with ggplot2 and I know that sjPlot uses ggplot2 under the hood.

I have tried:

theme_set(theme_gray(base_size = 20))

M--
  • 25,431
  • 8
  • 61
  • 93
TarJae
  • 72,363
  • 6
  • 19
  • 66
  • maybe there is a better way, but I think you can save your plot and change the `aes` in that object. – M-- May 21 '23 at 19:35
  • 1
    Also I cannot reproduce the results you are showing above: https://i.stack.imgur.com/KN7Qe.png – M-- May 21 '23 at 19:58
  • 2
    You can adjust the default size for the geometry used under the hood like this: `update_geom_defaults('text', list(size = 10))`, *then* call `plot_xtab`. – I_O May 21 '23 at 22:01
  • @M-- This is interesting, because on my posit cloud I do not have this problem? What could be the reason for this? – TarJae May 22 '23 at 20:36
  • @I_O Thank you very much. I have to test it on my desktop PC. I will give you a note. If it solve my problem your comment should be an answer! – TarJae May 22 '23 at 20:37
  • 1
    @TarJae I don't actually think it's related, but I had to load an older version of emmeans (newest version is only compatible with the latest R, so I loaded 1.7.9 from guthub; dependency of sjstats). Check your package versions and try running it in a fresh session. – M-- May 22 '23 at 20:47

0 Answers0