i'm unclear on why geom_text
's size unit is mm and not mm/the magic number in ggplot2:::.pt.
Also why it is apparently unaffected by global changes in text size via theme()
is there a rationale for geom_text
being excluded from these behaviours?
Some others who seem a little unclear on this:
r, ggplot2
r, ggplot2
opened 12:24PM - 05 Oct 16 UTC
closed 12:25PM - 05 Oct 16 UTC
I am playing with the export of ggplot2 package and I need to control all the fo… nt sizes. It seems however that `size` in `geom_text` is not a fontsize. This is a bit confusing, since it is not clear what it is exactly.
The reproducible example is straight from `geom_text` help page:
```
p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars)))
p + geom_text(size = 10)
```
The resulting labels are not font size 10. Here is my `devtools::session_info()`
```
Session info --------------------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin13.4.0
ui RStudio (0.99.1194)
language (EN)
collate fr_FR.UTF-8
tz Europe/Vilnius
date 2016-10-05
Packages ------------------------------------------------------------------------
package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.3.0)
chron 2.3-47 2015-06-24 CRAN (R 3.3.0)
colorspace 1.2-6 2015-03-11 CRAN (R 3.3.0)
data.table * 1.9.6 2015-09-19 CRAN (R 3.3.0)
DBI * 0.4-1 2016-05-08 CRAN (R 3.3.0)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.0)
digest 0.6.10 2016-08-02 cran (@0.6.10)
dplyr * 0.5.0 2016-06-24 CRAN (R 3.3.0)
DT * 0.2 2016-08-09 CRAN (R 3.3.0)
dtplyr * 0.0.1 2016-06-27 CRAN (R 3.3.0)
emiloop * 0.1.0 2016-09-21 local
ggplot2 * 2.1.0.9001 2016-10-05 Github (hadley/ggplot2@5a18687)
ggvis * 0.4.2 2015-06-06 CRAN (R 3.3.0)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.0)
htmltools 0.3.5 2016-03-21 CRAN (R 3.3.0)
htmlwidgets 0.6 2016-02-25 CRAN (R 3.3.0)
httpuv 1.3.3 2015-08-04 CRAN (R 3.3.0)
jsonlite * 1.0 2016-07-01 CRAN (R 3.3.0)
labeling 0.3 2014-08-23 CRAN (R 3.3.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0)
magrittr * 1.5 2014-11-22 CRAN (R 3.3.0)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.0)
mime 0.5 2016-07-07 CRAN (R 3.3.0)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.0)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.0)
pool * 0.1.0 2016-08-08 Github (rstudio/pool@a0fa5ac)
R6 2.1.3 2016-08-19 cran (@2.1.3)
Rcpp 0.12.7 2016-09-05 cran (@0.12.7)
RMySQL * 0.10.9 2016-05-08 CRAN (R 3.3.0)
rsconnect 0.4.3 2016-05-02 CRAN (R 3.3.0)
scales 0.4.0 2016-02-26 CRAN (R 3.3.0)
shiny * 0.14 2016-09-10 CRAN (R 3.3.0)
shinydashboard * 0.5.1 2015-09-09 CRAN (R 3.3.0)
shinythemes * 1.0.1 2015-03-03 CRAN (R 3.3.0)
showtext * 0.4-4 2015-10-30 CRAN (R 3.3.0)
showtextdb 1.0 2015-03-10 CRAN (R 3.3.0)
stringi 1.1.1 2016-05-27 CRAN (R 3.3.0)
stringr * 1.0.0 2015-04-30 CRAN (R 3.3.0)
sysfonts * 0.5 2015-04-27 CRAN (R 3.3.0)
tibble 1.2 2016-08-26 cran (@1.2)
tidyr 0.5.1 2016-06-14 CRAN (R 3.3.0)
withr 1.0.2 2016-06-20 CRAN (R 3.3.0)
xtable 1.8-2 2016-02-05 CRAN (R 3.3.0)
```
hadley
December 13, 2017, 5:45pm
2
a) To match the sizes of points and lines
b) Because theme settings only affect non-data components of the plot. (Although we might change this in the future: https://github.com/tidyverse/ggplot2/issues/2239 )
Thanks Hadley,
I intutively mapped geom_text()
into a mental category of 'texty' things which have font sizes, not into the category of 'data-pointy' things which don't. Depending on what proportion of people put this in what mental category it might make more sense from a user-friendliness perspective to default to font sizes and have people transform it by the magic number to get mm if they want.
I agree with the poster of that issue that expanding themes to affect non-data components seems like a good idea.