wilkelab / ggridges

Ridgeline plots in ggplot2
https://wilkelab.org/ggridges
GNU General Public License v2.0
411 stars 31 forks source link

X scale limits are not adjusted if rel_min_height cutoff is used #8

Open adrfantini opened 6 years ago

adrfantini commented 6 years ago

X scale limits should be updated according to the rel_min_height values. See the example plot (exaggerated):

ggplot(iris, aes(x = Sepal.Length, y = Species)) +
       geom_density_ridges(rel_min_height = 0.5) +
       scale_y_discrete(expand = c(0.01, 0)) +
       scale_x_continuous(expand = c(0.01, 0))

The scale should from 4.5 to ~7, instead it goes from ~4 to ~9, which is the same as rel_min_height = 0. I can see this as useful sometimes, other times it just wastes useful space, so maybe an option to crop it would be nice.

clauswilke commented 6 years ago

Hm, that's actually non-trivial. I'd have to completely change the logic of when these points are removed. I agree that the current behavior is not quite right, though.

adrfantini commented 6 years ago

Well one can manually set limits, so it should not be high on the list of priorities. Thanks for considering it anyway.

colinorourke commented 2 years ago

Well one can manually set limits, so it should not be high on the list of priorities. Thanks for considering it anyway.

This is very difficult to do when you have faceted plots. Let's say you've used facet_grid to make some ridges faceted by two variables. But due to some peculiarities of your data one of the densities has a long, tail. Then if you use rel_min_height the x-axis limits appear greatly expanded for that column and it is essentially impossible to fix this. Therefore, I think this issue is actually important.