mikeroswell / ratioScales

Development of ratio scales package for plotting
https://mikeroswell.github.io/ratioScales/
1 stars 1 forks source link

define function for each axis with `scale_*_ratio` #9

Closed mikeroswell closed 1 year ago

mikeroswell commented 2 years ago

In ggplot2, scale_x_continuous and scale_y_continuous are coded as duplicated functions with only the characters "x" and "y" replaced in the function name and as the aesthetics argument to ggplot2::continuous_scales(); other named variations such as scale_x_log10() etc. similarly copy functions verbatim for "x" and "y". Is this the best practice, and how we should proceed to define the "ratio scales" for x and y axes?

https://github.com/tidyverse/ggplot2/blob/main/R/scale-continuous.r

bbolker commented 2 years ago

will take a look when I get a chance ... I guess if that's the way it's done in ggplot that we should follow their lead ... ? (i.e. that suggests that abstracting/generalizing across axes will be hard ... ?)

mikeroswell commented 1 year ago

Look to refactor using continuous_scale c.f. https://github.com/tidyverse/ggplot2/blob/main/R/scale-.r Might be able to get the flags and downstream functions to happen lower down in scale construction, and then call the scaling with scale_x_ratio and scale_y_ratio (which i think most people will be using most of the time anyways).