mjskay / ggdist

Visualizations of distributions and uncertainty

Home Page:https://mjskay.github.io/ggdist/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide an `overflow` option to decide what to do when binwidth constraints are hit

mjskay opened this issue · comments

Along with #161, another way to help with scaling would be to allow stackratio and dotsize to be automatically selected when a binwidth constraint is hit (definitely a min, and maybe also a max?). For example, this would allow the automatic layout algorithm to guarantee both a minimum dot size and that the entire dotplot fits in the available space (currently it can guarantee the latter, but only by allowing dots to become arbitrarily small).

Currently, if binwidth is a range and the automatic binwidth algorithm choses a binwidth below the minimum of that range, the minimum binwidth will be used, but this can cause the tallest stack of dots to exceed the geom boundaries. However, we could allow some alternatives:

  1. if binwidth is a range and the automatically selected binwidth is less than the user-specific minimum, pick a dotsize to make the visual dot size equal to the user-specified minimum binwidth, then pick stackratio such that the tallest bin touches the geom edge.

On second thought, this really shouldn't be triggered by setting stackratio and dotsize to NA... esp since this changes the meaning of binwidth to be effective dot size, and means that desired (baseline) stackratio and dotsize can't be set, but have to be fixed to 1.

Instead, maybe an option like overflow = "compress" that would compress the stackratio (and maybe increase dotsize) on overflow? Would be a more transparent way of setting what to do when binwidth constraints are hit.