grantmcdermott / tinyplot

Lightweight extension of the base R graphics system
https://grantmcdermott.com/tinyplot
Apache License 2.0
226 stars 7 forks source link

Wishlist: Refined methods for densities/histograms #21

Closed zeileis closed 2 months ago

zeileis commented 1 year ago

In addition to the plot2.density method from PR https://github.com/grantmcdermott/plot2/pull/18, it would be nice to have a formula-based interface:

plot2(~ x | by, type = c("density", "histogram"), ...)

where it can be selected which display is used for x in each by group.

In addition to just lines it would be nice to support semi-transparent shaded areas below the lines as well (via polygon()). The area might also be opaque if we order the by groups (e.g., by median) from highest to lowest, which would yield a kind of ridge lines plot.

GM edit: adding task items to track.

harrelfe commented 8 months ago

I would rather see type='histogram' or 'density' handled in a general way where the user provides a function that transforms one variable into two dimensions (e.g., original value and height of estimated density function), and have the function also provide a few more details (e.g., type='l' vs. type='b' or 'p' or 'bar').

grantmcdermott commented 8 months ago

I would rather see type='histogram' or 'density' handled in a general way where the user provides a function that transforms one variable into two dimensions (e.g., original value and height of estimated density function), and have the function also provide a few more details (e.g., type='l' vs. type='b' or 'p' or 'bar').

Thanks for the suggestion. I have something along those lines here (see "User-supplied functions" near the bottom).