-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
From the aesthetic specificiations vignette:
Due to a historical error, the unit of linewidth is roughly 0.75 mm. Making it exactly 1 mm would change a very large number of existing plots, so we’re stuck with this mistake.
For the linewidth, we can compare a line geom, width a grid rectangle with known units and see the above is likely true.
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.5.2
ggplot() +
annotate(
"line", x = c(0, 2), y = 1, linewidth = 20, alpha = 0.5
) +
annotate(
"point", 1, 1, size = 50, shape = 21, stroke = 20,
alpha = 0.5
) +
annotation_custom(
grid::rectGrob(height = unit(20, "mm"), gp = grid::gpar(fill = NA))
)Created on 2025-12-03 with reprex v2.1.1
However for stroke, the vignette states:
The size of the filled part is controlled by size, the size of the stroke is controlled by stroke. Each is measured in mm, and the total size of the point is the sum of the two.
And we can see, from the point in the plot above, that the stroke seems narrower than the linewidth. If we measure the thickness (difference between inner and outer radii) for the point, we measure 10mm instead of the 20mm we thought we specified. In addition, the point as a whole measures 57.6mm in diameter, instead of the 50mm + 20mm the vignette tells us it would be.
So the stroke aesthetic is inconsistent with the linewidth aesthetic, it is half of what the vignette tells us it should be and it doesn't add to the total size of the point as expected.
I guess it is too late to change this now, but should we maybe provide an option to have the millimetre interpretation?
