ggplot2 - The unit of size

前端 未结 3 1758
抹茶落季
抹茶落季 2020-11-27 03:51

A quick question that I can\'t find answer on the web (or Wickham\'s book):

What is the unit of the size argument in ggplot2? For example, geom_tex

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 04:44

    The 'ggplot2' package, like 'lattice' before it, is built on the grid package. You can get the available units at:

    ?grid::unit
    ?grid::convertX
    ?grid::convertY
    
    grid::convertX(grid::unit(72.27, "points"), "inches")
    

    (I use the formalism pkg::func because in most cases grid is loaded a a NAMESPACE but not attached when either lattice or `ggplot2 are loaded.)

    I earlier posted a comment that I later deleted saying that size was in points. I did so after seeing that the size of the text with size=10 was roughly 10 mm. The "magic" number mentioned by agstudy is in fact within 1% of:

    as.numeric(grid::convertX(grid::unit(1, "points"), "mm"))
    #[1] 0.3514598
    0.352777778/.Last.value
    #[1] 1.00375
    

提交回复
热议问题