-
Notifications
You must be signed in to change notification settings - Fork 109
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
tickmark/break calculations with exp_trans, probability_trans fail often #59
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I get problems using atan transformations. What I believe happens is:
When creating a transformation you can specify the domain of the function. library(ggplot2)
library(scales)
atan_trans <- trans_new(
name = "atan",
transform = function(x) atan(x),
inverse = function(x) tan(x),
breaks = function(x) {
print(x)
breaks <- extended_breaks()(x)
print(breaks)
breaks
}
)
plot(atan_trans, xlim = c(-10, 10)) data <- data.frame(
x1 = seq(-2, 2, length = 10),
x2 = seq(-5, 5, length = 10),
x3 = seq(-20, 20, length = 10)
)
ggplot(data = data) +
geom_point(aes(x1, 1)) +
scale_x_continuous(trans = atan_trans)
Created on 2019-10-31 by the reprex package (v0.3.0)
Original code
More details:
|
I wrote: |
Thanks @TimHesterberg — I think your analysis of the problem is correct. I think the right way to resolve this is to add a |
No, that doesn't make sense because the ... Problem with providing range is that it's not necessarily fixed for all transformations in a family so it would be more general to provide an expand parameter that was a function that took the limits and returned the expanded values. |
I'm running into this problem frequently with the library(ggplot2)
dat <- data.frame(x = 5:100)
ggplot(dat) +
aes(x = x, y = x) +
scale_y_continuous(trans = "exp")
#> Warning in self$trans$inverse(limits): NaNs produced
#> Error in if (zero_range(as.numeric(limits))) {: missing value where TRUE/FALSE needed Created on 2021-10-09 by the reprex package (v2.0.1) Is there any possibility this transformation might be fixed? |
Seconding this. Is there anyway to circumvent this problem? |
Might be partially resolved by tidyverse/ggplot2#4775. It gets rid of the warnings/errors, but perhaps the transformation could do with some refinement in choosing breaks. # remotes::install_github("tidyverse/ggplot2#4775")
library(ggplot2)
dat <- data.frame(x = 5:100)
ggplot(dat) +
aes(x = x, y = x) +
geom_point() +
scale_y_continuous(trans = "exp") Created on 2022-04-15 by the reprex package (v2.0.1) |
Closed in favour of #405 |
Some ranges seem to break the calculation of the breaks/tickmarks for these transformed axes:
It works for
y <- 1:3
,y <- (-10):-7
, e.g., but I haven't found an example with more than 4 values that worked ... ?!?Created on 2019-10-31 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: