In ggplot2, it is easy to use element_textwith an argument size=6to set the font size to 6 pt (for text, the size has a pt block). However, we cannot use element_linewith an argument size=0.5to set the line width to 0.5 pt (for a line, the size does not have one). So how to solve this problem?
In the package gridI meet a similar question. The code is as follows:
library(grid)
grid.rect(width=unit(5, "cm"), height=unit(5, "cm"), gp=gpar(lwd=unit(2, "cm")))
and the result:

Obviously, the line width is not equal to 2 cm compared to the width or height of the rectangle.
Tiger source
share