Skip to content

Instantly share code, notes, and snippets.

@djnavarro
Last active May 13, 2019 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djnavarro/e1dabb01aa3a5a3dea534c09c2f4e84d to your computer and use it in GitHub Desktop.
Save djnavarro/e1dabb01aa3a5a3dea534c09c2f4e84d to your computer and use it in GitHub Desktop.
example where coord_trans throws many warnings
# from section 7.5.1 of ggplot2 book
library(ggplot2)
base <- ggplot(diamonds, aes(carat, price)) +
stat_bin2d() +
geom_smooth(method = "lm") +
xlab(NULL) +
ylab(NULL) +
theme(legend.position = "none")
pow10 <- scales::exp_trans(10)
base +
scale_x_log10() +
scale_y_log10() +
coord_trans(x = pow10, y = pow10) # <-- many warnings thrown here
# Warning messages:
# 1: In self$trans$x$inverse(panel_params$x.range) : NaNs produced
# 2: In self$trans$y$inverse(panel_params$y.range) : NaNs produced
# 3: In self$trans$x$inverse(panel_params$x.range) : NaNs produced
# 4: In self$trans$y$inverse(panel_params$y.range) : NaNs produced
# etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment