change the font size of a plot made with eulerr in r

To change the font size of a plot made with eulerr in R, you can use the theme function along with the text option to change the font size of various plot elements, including the plot title, axis labels, and legend.

Here is an example code block showing how to change the font size of an eulerr plot:

main.r
library(eulerr)
library(ggplot2)

# create example eulerr plot
eulerr::euler(c("Group1" = 20, "Group2" = 30, "Group3" = 15),
              c("Group1" = 10, "Group2" = 25, "Group4" = 5))

# change the font size of plot elements
theme_set(theme_bw(base_size = 16)) # set base font size
theme(title = element_text(size = 20),      # change plot title font size
      axis.title = element_text(size = 18), # change axis label font size
      legend.text = element_text(size = 14)) # change legend font size
503 chars
13 lines

In this example, theme(title = element_text(size = 20) changes the font size of the plot title to 20, axis.title = element_text(size = 18) changes the font size of the axis labels to 18, and legend.text = element_text(size = 14) changes the font size of the legend text to 14. The theme_bw() function is used to set the base size of the font to 16, which will affect all other elements not specified within the theme() function.

related categories

gistlibby LogSnag