ggvis icon indicating copy to clipboard operation
ggvis copied to clipboard

Scale expansion causes log scales to display incorrectly

Open wch opened this issue 11 years ago • 3 comments

This is because the expansion can cause the scale domain to contain negative values, which don't work with log scales.

p <- pressure %>%
  ggvis(~temperature, ~pressure) %>%
  layer_lines()
p

# Problem:
p %>% scale_numeric("y", trans = "log")

# OK:
p %>% scale_numeric("y", trans = "log", expand = 0)

wch avatar Jul 31 '14 03:07 wch

+1. This should not fail silently; at least a warning would be nice.

dholstius avatar Feb 03 '15 18:02 dholstius

Hi, expand = 0 seems to work in this example but it does not work on my dataset. I assume that your solution is only applicable to pre-baked data set such as mtcars or pressure? I tried both scale_numeric("y", trans = "log", expand = 0) and ~log10(data) directly in mapping.... They both result in the same plot. tmp

udaniel avatar Aug 04 '15 14:08 udaniel

@udaniel Check if your data contains a 0. That was the problem with mine.

tomhiatt avatar Oct 20 '15 07:10 tomhiatt