In a ggplot chart I have a title for chart and values for x and y axis. When I save the chart as an image the labels are tiny.
I tried to change the font size using:
size = 21
But it didn't work. Is there any easy way to chage the font size for the whole chart?
There are two ways to set the global font size in a ggplot object
p = ggplot(data, aes(x=x, y=y))
. As Didzis pointed out one can specify:
global_size = 10
p + theme(text = element_text(size=global_size))
Alternatively, if you are using one of the ggplot themes, pass base_size
argument:
p + theme_classic(base_size = global_size)
This is subjective, but I would advise against using font size 21. It is better to use "standard" font sizes (9-12 pt) and adjust the height
and width
when saving the ggplot object to match your final printed output.
Just measure the width / height in inches (or cm) of the figure in your presentation, report, etc and save the plot p
with exactly those dimensions
ggsave(p, filename=filename,
width=width_measured, height=height_measured, units='cm')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With