1

I've been looking what seems to be everywhere. I would like to know what the default unit size of annotate() is in ggplot2, as I'm not able to set size to a specific unit in annotate().

For example, I tried the following, but it didn't work:

annotate(geom = "text", label = "Am I a bird?",
           x = "ABC", y = 2375/2,
           family = "Arial", size = unit(10, "mm"), colour = "white")

Error in checkNA("fontsize") : 
  mixture of missing and non-missing values for fontsize

Thanks for your help!

5
  • 1
    The size of text is measured in mm. Simply using size = 10 therefore results in a font size of 10mm. If you want want to draw a 10pt text instead, set size = 10 / ggplot2::.pt. See ggplot2.tidyverse.org/articles/ggplot2-specs.html#text. Commented Mar 23, 2020 at 21:58
  • 1
    funnily, this is a constant. To convert to your desired pt, factorise your annotate font size by 5/14 Commented Mar 23, 2020 at 23:59
  • That worked perfectly, @Tjebo ! Thanks a lot. How did you know it was exactly that factor? Is there an online resource somewhere? Commented Mar 24, 2020 at 0:04
  • 1
    I saw it a couple of years ago somewhere. One of those things... The online resource is actually provided by @IanCampbell in their answer - 14/5 is roughly the same. Commented Mar 24, 2020 at 0:08
  • 1
    here we go - I think this was the thread. stackoverflow.com/questions/25061822/… Commented Mar 24, 2020 at 0:11

1 Answer 1

4

It says here that the default unit is mm. So if you want to go from points to mm multiply by 72.27 / 25.4.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.