Closed jkeuskamp closed 1 year ago
But this works fine:
library(units)
mtcars$consumption <- set_units(mtcars$mpg, mi / gallon)
mtcars$power <- set_units(mtcars$hp, hp)
ggplot(mtcars) +
geom_point(aes(power, consumption)) +
scale_x_units(unit = "W", trans="reverse")
So I'm not sure what are you proposing exactly.
It does indeed but takes some digging, but it would be more convenient if units would support all ggplot varieties of scale_*_continous. I agree it is not a very pressing issue though 👍
So you propose having scale_x_units_reverse
, scale_x_units_log10
and so on? Just to clarify, because clearly we cannot make scale_x_reverse
call scale_x_units
, because scale_x_reverse
is, by definition, an alias of scale_x_continuous
with that transformation applied.
I would propose to edit the documentation of scale_units to say that the transformation convenience functions included with ggplot (scalelog10(), scalesqrt(), scale_reverse(), are not supported and include an example like:
ggplot(mtcars) + geom_point(aes(power, 1 / consumption)) + scale_y_units(trans= reverse_trans()) }
From: Iñaki Ucar @.> Date: Friday, 24 February 2023 at 10:34 To: r-quantities/units @.> Cc: Keuskamp, J.A. (Joost) @.>, Author @.> Subject: Re: [r-quantities/units] support for scale_*_reverse() (Issue #343)
So you propose having scale_x_units_reverse, scale_x_units_log10 and so on?
— Reply to this email directly, view it on GitHubhttps://github.com/r-quantities/units/issues/343#issuecomment-1443345170, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHKBHAEDY7DN3MIJT4RKWLWZB6D5ANCNFSM6AAAAAAVGVAEA4. You are receiving this because you authored the thread.Message ID: @.***>
A feature request rather than a bug: Units facilitates the usage of ggplot with units rather seamlessly. A small shortcoming is the usage of
scale_*_reverse()
. This fails withbecause
scale_*_reverse()
callsscale_y_continuous(trans = scales::reverse_trans())
to invert the axis. It would be convenient ifscale_*_reverse()
would callscale_y_units(trans = scales::reverse_trans())
when applicable.