font size in scale_x_discrete

4,453 views
Skip to first unread message

Manuel Spínola

unread,
Mar 15, 2011, 9:17:26 PM3/15/11
to ggplot2
Dear list members,

Is it possible to manage the font size in scale_x_discrete?

scale_x_discrete(breaks=c("M", "SM"), labels=c("Manejo <15 años", "Manejo >15 años"))

Best,

Manuel

--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.ac.cr
mspin...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río
Institutional website: ICOMVIS

Dennis Murphy

unread,
Mar 15, 2011, 10:25:47 PM3/15/11
to Manuel Spínola, ggplot2
Hi:

Use opts(axis.text.x = theme_text(size = xx)), where xx is the desired font size.

# Example:
df <- data.frame(gp = rep(c('M', 'SM'), each = 10),
                  y = rnorm(20, m = rep(c(5, 8), each = 10)) )
ggplot(df, aes(x = gp, y = y)) + geom_boxplot() +

    scale_x_discrete(breaks=c("M", "SM"), labels=c("Manejo <15 años", "Manejo >15 años"))
 last_plot() +  opts(axis.text.x = theme_text(size = 14))

HTH,
Dennis

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Manuel Spínola

unread,
Mar 16, 2011, 7:20:57 AM3/16/11
to Dennis Murphy, ggplot2
Thank you very much Dennis.

Manuel

g pc

unread,
Apr 13, 2020, 8:44:43 AM4/13/20
to ggplot2
Hi All:
Please note that the option is now:
theme( axis.text = element_text(size=14))  for both axes. Use axis.text.x or axis.text.y for the obvious axes.
G
Reply all
Reply to author
Forward
0 new messages