Increase legend font size ggplot2

1.2K    Asked by FelicaLaplaca in Python , Asked on Jul 5, 2021

Is there a way to increase the font size in ggplot2? I think I need to specify something like legend.key.width = unit(2, "line") in the theme function, but that is used to adjust the keys in legends, not the font sizes. How to increase ggplot legend text size?

Answered by Abigail Abraham

To increase ggplot legend text size, you can add the following to your plot:


 theme(legend.text=element_text(size=X))

Where

X is the size.

For example:ggplot(data = iris,

       aes(x = Sepal.Length, y = Sepal.Width,col = Species, label = Species)) + 
  geom_point() +
   theme(legend.text=element_text(size=15))

Output:



Your Answer

Interviews

Parent Categories