Skip to content
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

Incorrect scale expansion with log scales #1696

Closed
wch opened this issue Aug 4, 2016 · 8 comments
Closed

Incorrect scale expansion with log scales #1696

wch opened this issue Aug 4, 2016 · 8 comments
Assignees

Comments

@wch
Copy link
Member

wch commented Aug 4, 2016

I haven't been able to make a super-minimal reproducible example, but here's one that uses real data:

library(ggplot2)
library(scales)

dat <- structure(list(nrow = c(10, 100, 1000, 10000, 1e+05, 10, 100, 
1000, 10000, 1e+05, 10, 100, 1000, 10000, 1e+05, 10, 100, 1000, 
10000, 1e+05, 10, 100, 1000, 10000, 1e+05, 10, 100, 1000, 10000, 
1e+05, 10, 100, 1000, 10000, 1e+05, 10, 100, 1000, 10000, 1e+05
), method = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 6L, 
6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L), .Label = c("apply", 
"split_lapply", "lapply_row", "lapply_lapply", "by_row", "pmap", 
"pmap_aslist", "rowwise"), class = "factor"), seconds = c(0, 
0.00400000000081491, 0.0059999999939464, 0.0659999999988941, 
0.921000000002095, 0.00100000000384171, 0.245000000002619, 0.0639999999984866, 
0.856999999996333, 35.1150000000052, 0.00100000000384171, 0.00700000000506407, 
0.0619999999980791, 0.833000000005995, 30.3260000000009, 0, 0.0029999999969732, 
0.0339999999996508, 0.471000000005006, 3.62299999999959, 0, 0.000999999996565748, 
0.00499999999738066, 0.0529999999998836, 0.594000000004598, 0.00400000000081491, 
0.00300000000424916, 0.0250000000014552, 0.273999999997613, 2.91700000000128, 
0, 0, 0.0029999999969732, 0.0169999999998254, 0.222000000001572, 
0.00200000000040745, 0.00600000000122236, 0.0639999999984866, 
0.588999999999942, 8.83099999999831)), row.names = c(NA, -40L
), .Names = c("nrow", "method", "seconds"), class = "data.frame")

ggplot(times, aes(x = nrow, y = seconds, colour = method)) +
  geom_point() +
  geom_line() +
  scale_y_continuous(trans = log10_trans()) +
  scale_x_continuous(trans = log10_trans())

image

Here's an attempt at a minimal example, but it doesn't reproduce the problem:

dat <- data.frame(x = 10^(1:10), y = 10^(1:10))

ggplot(dat, aes(x, y)) +
  geom_point() +
  scale_y_continuous(trans = log10_trans()) +
  scale_x_continuous(trans = log10_trans())

image

@hadley
Copy link
Member

hadley commented Aug 5, 2016

Here's a minimal reprex:

df <- data.frame(x = c(1e1, 1e5), y = c(0, 100))

ggplot(df, aes(x, y)) +
  geom_point(size = 5) +
  scale_y_log10() 

The cause is left as an exercise for the reader 😉

@thomasp85
Copy link
Member

Shouldn't scale_y_log10 throw an error, or is this by design?

@thomasp85 thomasp85 self-assigned this Aug 8, 2016
@hadley
Copy link
Member

hadley commented Aug 8, 2016

Something should probably throw a warning, but the placement of -Inf & Inf points is by design.

@thomasp85
Copy link
Member

Maybe a general warning when plotting inf?

@hadley
Copy link
Member

hadley commented Aug 8, 2016

I don't think that will work because it's used deliberately

@thomasp85
Copy link
Member

As a feature or a fallback?

@hadley
Copy link
Member

hadley commented Aug 8, 2016

As a feature - i.e. if you want a geom_rect() that span the full height, you set ymin = -Inf, ymax = Inf

@thomasp85
Copy link
Member

I see. Than a broad mechanism for catching transformations that result in conversion to non-real numbers...

thomasp85 added a commit that referenced this issue Aug 25, 2016
Check for occurence of infinite values Fixes #1696
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants