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
awkward behavior from scale_fill_viridis_c(trans = "log") #4185
Comments
Some of the issues you are getting are related to what happens when you take logarithms of non-positive numbers. seq(-1, 1, by = 0.5)
#> [1] -1.0 -0.5 0.0 0.5 1.0
log(seq(-1, 1, by = 0.5))
#> Warning in log(seq(-1, 1, by = 0.5)): NaNs produced
#> [1] NaN NaN -Inf -0.6931472 0.0000000 The NaN's appear because logarithms for negative numbers are undefined. NaN is generally treated differently than NA. |
I also ran into this and I think these lines are responsible: Lines 597 to 598 in aaaec2f
Which is fine for position scales, but generates these awkward messages for other types of scales. I'm not sure how safe this is, but it might be possible to replace the first line in the chunk above by
At least, that is how In a similar vein, Lines 1185 to 1191 in aaaec2f
It think an alternative might be to consider to use the |
In general, you have to be prepared for |
Three interrelated issues:
scale_fill_viridis_c(na.value = "transparent", trans = "log")
, which plots fine since apparently -Inf, NaN, and NA are treated interchangeably but is orthogonal to warning generation.format_format(digits = n)
provides a simple mitigation.Observed on R 4.0.2 with tidyverse 1.3.0 (ggplot 3.3.2). I suspect this might also occur with other scale_fill functions.
The text was updated successfully, but these errors were encountered: