-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Legend for geom_col()
's size does not correctly depict change in size
#4852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks, confirmed. I'm not sure if this is a bug or a spec at the moment, but looks strange... library(ggplot2)
exp_df <- data.frame(x = letters[1:3], size = c(1, 4, 16))
ggplot(exp_df, aes(x, 1L, size = size)) +
geom_col(colour = "red", fill = "transparent") +
theme(
legend.key.size = unit(0.2, "npc"),
legend.position = "top"
) +
scale_size_identity(guide = "legend") Created on 2022-05-21 by the reprex package (v2.0.1) |
I now think this is a reasonable behavior. In Lines 68 to 73 in 411f17b
The limit size is determined by the width and height of the key. Lines 637 to 647 in 411f17b
Apparently, the legends are usually smaller than the actual drawings in the plots, so I think limiting the line size is reasonable, otherwise the legend might overflow. But, if I understand correctly, ggplot2 doesn't provide any option to change that limit. We might expose some parameter for this, but I have no idea. |
The |
Thanks, but I think we should fix |
Also wondering: on my plot examples' canvas, any idea why the size step between 1 and 2 seems different to the other steps (2 to 3 and 3 to 4), i.e. a bigger jump in size? It doesn't seem to be a linear change and looks odd to me. |
Because, by default, |
To clarify, |
I'm not sure if this is related to issue #3729 at all, but here it is: when using the
size
aesthetic for a bar/col geometry, the corresponding legend does not match differences in sizes in the plot like e.g. a point geometry would. This is especially true if thecolour
aesthetic is also mapped to a variable from the dataset, as the outline completely disappears from the legend and therefore the audience might think that it's the darker area that depicts the size:Created on 2022-05-18 by the reprex package (v2.0.1)
There is a very slight different in size (2 pixels) between the first square and the three others in the legend, but that's it:
The text was updated successfully, but these errors were encountered: