Conversation
Codecov Report
@@ Coverage Diff @@
## main #294 +/- ##
==========================================
- Coverage 93.15% 92.93% -0.22%
==========================================
Files 18 19 +1
Lines 862 906 +44
==========================================
+ Hits 803 842 +39
- Misses 59 64 +5
Continue to review full report at Codecov.
|
|
Thanks, @edzer. And @krlmlr thanks for your reference implementation in |
|
Thanks, good catch: data <- tibble::tibble(
x = pillar::num((1:10) / 100, fixed_exponent = -3, notation = "eng"),
y = pillar::num((1:10) / 100, scale = 100, label = "%"),
z = pillar::num(10^(-5:4), notation = "si")
)
data
#> # A tibble: 10 × 3
#> x y z
#> <eng> % <si>
#> 1 10e-3 1 10µ
#> 2 20e-3 2 100µ
#> 3 30e-3 3 1m
#> 4 40e-3 4 10m
#> 5 50e-3 5 100m
#> 6 60e-3 6 1
#> 7 70e-3 7 10
#> 8 80e-3 8 100
#> 9 90e-3 9 1k
#> 10 100e-3 10 10k
ggplot2::ggplot(data, ggplot2::aes(x, y)) +
ggplot2::geom_point()Created on 2021-12-28 by the reprex package (v2.0.1) I'll try to fix in pillar. |
|
This is a current limitation, about to file a ggplot2 issue. For now, should |
Great, thanks.
That's a very good idea. |
|
9ec86ee will do for now. In our case, I used library(ggplot2)
mtcars$consumption <- units::set_units(mtcars$mpg, mi / gallon)
mtcars$power <- units::set_units(mtcars$hp, hp)
ggplot(mtcars) +
geom_point(aes(power, consumption))
#> Error in scale_type.units(x): Variable of class 'units' found, but 'units' package is not attached.
#> Please, attach it using 'library(units)' to properly show scales with units.
ggplot(mtcars) +
geom_point(aes(power, consumption)) +
units::scale_x_units(unit = "W") +
units::scale_y_units(unit = "km/l")library(units)
#> udunits database from /usr/share/udunits/udunits2.xml
ggplot(mtcars) +
geom_point(aes(power, consumption))Created on 2021-12-28 by the reprex package (v2.0.1) |



@edzer I've adapted the code from
ggforceand added Thomas as a contributor in the DESCRIPTION. I've called the functionsscale_*_unitsinstead ofscale_*_unitto follow the naming conventions. I've also droppedggforcefrom the DESCRIPTION, demos and vignettes, but preserving the mention in the ACKs (i.e., this). Is that ok?