Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change size of legend in ggplot2

Tags:

r

ggplot2

This code:

ggplot(mapping = aes(x = x, y = y)) +
  geom_line(data = error_Legendre, aes(colour = "Legendre")) +
  geom_line(data = error_LLm10, aes(colour = "LL")) +
  xlab('x') +
  ylab('y')+
  scale_colour_manual(
    values = c("blue", "red")
  )+theme(axis.text=element_text(size=20))

changes correctly the axis text. I would like to change the size of the legend, i.e. Legendre and LL.

like image 306
Mark Avatar asked Sep 14 '25 14:09

Mark


1 Answers

add this in your theme : +theme(axis.text=element_text(size=20), legend.text = element_text(size=10)) but do know there are several options for core text, titles, etc. This page lists the options : https://www.statology.org/ggplot2-legend-size/

like image 77
Abi T. Avatar answered Sep 16 '25 02:09

Abi T.