ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Use ggplot2_global in aes_to_scale

Open thomasp85 opened this issue 1 year ago • 4 comments

I discovered that coord$transform() doesn't transforms all the x and y aesthetics that are given in ggplot_global$x_aes/ggplot2_global$y_aes. Indeed, aes_to_scale() which is used in transform_position() has it's own hard coded values to look up.

It seems to me this is a leftover from back when we didn't have a central repository for positional aesthetic names and we should change it... however I'm hazy on whether it would have unforeseen consequences...

@clauswilke @yutannihilation and @Hadley any thoughts agains?

thomasp85 avatar Aug 31 '22 12:08 thomasp85

Does the current code create incorrect transformations for some geoms? One would think so, but I'm not aware of any bug reports. Maybe it requires rather obscure input.

My main concern would be with transforming aesthetics that represent distances rather than positions (e.g., width or height), but those don't seem to be present in ggplot_global$x_aes/ggplot2_global$y_aes.

clauswilke avatar Aug 31 '22 14:08 clauswilke

It isn't used anywhere in the ggplot2 code base which is why we haven't caught it. But in ggforce I tried having x0 and y0 aesthetics and was perplexed why they weren't transformed seeing that they are valid positional aesthetics. So the fix is mostly for my own sake and for internal consistency

thomasp85 avatar Aug 31 '22 15:08 thomasp85

I see. In any case, it sounds reasonable to me to make this fix.

clauswilke avatar Aug 31 '22 16:08 clauswilke

I don't know well about these positional aesthetics, but it sounds fine to me.

yutannihilation avatar Sep 13 '22 16:09 yutannihilation