Font sizes in geom_text and theme_text

1,172 views
Skip to first unread message

Winston Chang

unread,
Feb 9, 2012, 2:53:12 AM2/9/12
to ggplot2-dev
Font sizes in geom_text/annotate seem to be very different from those in theme_text. In this example, both sizes are set to 12, but the result is very different:

ggplot(data.frame(x=1:3), aes(x=x, y=x)) + geom_point() +
    annotate(geom="text", x=2, y=2, label="Annotation text", size=12) +
    opts(title="This is a Title") +
    opts(plot.title=theme_text(family="Times", face="bold", size=12))



In the code for geom_text, the textGrob gets this, with units="native":
  fontsize = size * .pt,

In theme_text, the textGrob gets this, with units="npc":
 fontsize = size


.pt is defined in aaa-constants.r to be:
.pt <- 1 / 0.352777778


Anyone know why it's like this?

-Winston

Hadley Wickham

unread,
Feb 9, 2012, 8:35:01 AM2/9/12
to Winston Chang, ggplot2-dev

geoms uses mm for all sizes.

themes are not so consistent :/

Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages