pheymanss / chronicle

R package to create R Markdown reports with a sequential syntax inspired by ggplot
29 stars 4 forks source link

[Feature request] Flip coordinates and facets for make_raincloud() #42

Open lucazav opened 3 years ago

lucazav commented 3 years ago

It would be really useful to enrich the make_raincloud() function to provide a parameter to flip the coordinates of the plot (vertical rainclouds grouped along the horizontal axis) and another one to pass a set of variables to define the facet groups (like the split_groups_by for boxplots).

pheymanss commented 3 years ago

Those are rather good suggestions, split_groups_by would be also easily applicable to make_violin, and perhaps a similar logic could be applied to make_density and make histogram.

Regarding coord_flip on rainclouds, however, it will be quite troublesome since a key aspect of chronicle's functions is perfect feature parity between static ggplot2 plots and their plotly counterparts. All plots are translated through plotly::ggplotly, and raincloud plots are traditionally made with ggdist, whose geoms are not currently supported by ggplotly's translator engine. This means that I had to manually build each element of the raincloud segment by segment through geom_segment and the like. Applying coord_flip after the entire plot is done does not work, so this will necessitate a rather large workaround.