distributions3
distributions3 copied to clipboard
Refactoring plotting
Where I'm at so far:
-
I think having
plot_pdf()
andplot_cdf()
are valuable even if there is some code repetition because the names are the most clear, and beginners in my experience have struggled with function arguments (i.e.type = "cdf"
vstype = "pdf"
), and we can take away that potential snag via specialized functions names at little additional maintenance cost. -
I don't think that having two distinct plotting systems is beginning friendly. I think it is important that there is one canonical way to do things in this package. I'm actually increasingly convinced aliasing
plot()
andautoplot()
is going to cause beginner confusion. -
I don't particularly mind a
ggplot2
hard dependency.
- If you want to have separate
plot_pdf()
andplot_cdf()
functions, I would implement these as simple convenience interfaces to the more flexible underlyingplot()
function. Essentiallyplot_pdf <- function(x, ...) plot(x, what = "pdf", ..)
or something like that. This keeps the code DRY and facilitates maintenance while still providing shortcuts for beginners. - Many teachers will not have covered ggplot2 when using this package for basic probability theory - and conversely many teachers will not go into base graphics but only cover ggplot2. So I would be inclusive to all of these and provide infrastructure for both plotting paradigms. This necessitates some explanation for beginners but I think that even most of them are quickly aware of that both systems exist and work rather differently.
- I'm not particularly worried about a ggplot2 dependency. I just think that so far it can be avoided relatively easily without disadvantages for those who want to use it. The benefit would be a leaner list of inherited dependencies for for future reverse dependencies that are likely to use mostly the distributional functionality and not necessarily the visualization infrastructure.