ggmagnify icon indicating copy to clipboard operation
ggmagnify copied to clipboard

Fails with non-continuous scales

Open hughjonesd opened this issue 2 years ago • 3 comments

Test case which works fine without the call to scale:

ggplot(mtcars, aes(mpg, hp)) + 
  geom_point() + 
  scale_y_binned(n.breaks = 5) + 
  geom_magnify(x = 15, width = 5, y = 200, height = 100, to_x = 30, to_y = 200, magnify = c(1, 1.5))

hughjonesd avatar May 02 '23 11:05 hughjonesd

The underlying reason is https://github.com/tidyverse/ggplot2/issues/5294: xmin and xmax get trashed by scale_x_binned and friends.

hughjonesd avatar May 02 '23 15:05 hughjonesd

geom_magnify2 is a workaround

hughjonesd avatar May 03 '23 06:05 hughjonesd

Updated version where this still breaks:

ggplot(mtcars, aes(mpg, hp)) + 
  geom_point() + 
  scale_y_binned(n.breaks = 5) + 
  geom_magnify_tile(x = 15, width = 5, y = 200, height = 100, to_x = 30, to_y = 200, to_width = 5, to_height = 150)

or

ggplot(mtcars, aes(mpg, hp)) + 
  geom_point() + 
  scale_y_binned(n.breaks = 5) + geom_magnify(from = c(12.5, 150, 17.5, 250) , to = c(27.5,125, 32.5, 275))

hughjonesd avatar May 05 '23 04:05 hughjonesd