Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Make faceting optionally in a grid rather than just one column in tm_g_km #665

Closed
danielinteractive opened this issue Nov 3, 2022 · 5 comments · Fixed by #720
Assignees
Labels
core enhancement New feature or request sme

Comments

@danielinteractive
Copy link
Contributor

danielinteractive commented Nov 3, 2022

Currently the faceting in tm_g_km only works with one column. The plots get very "flat" then.
Sometimes it might be better to use a grid e.g. with 2 or 3 columns.

@danielinteractive danielinteractive added the enhancement New feature or request label Nov 3, 2022
@danielinteractive
Copy link
Contributor Author

danielinteractive commented Nov 3, 2022

@shajoezhu @lcd2yyz fyi

@mthbretscher
Copy link

mthbretscher commented Nov 29, 2022

The core issue is that "faceting" produces very disfigured (hight vs width) plots - they become very flat - and there's no one-size-fits-all setting for plot dimensions that could mitigate that. Either arrange faceting in a grid, or dynamically increase the plot height (multiply by the number of facets) could help..

@shajoezhu shajoezhu added the sme label Dec 1, 2022
@mthbretscher
Copy link

I found out a bit more on this - facetting actually works when a factor has only few levels (e.g. gender, with two levels). If I try to facet by a variable with many more levels (e.g. treatment category), then the plot height appears to be determined by total number of levels in that factor variable - not by the actual number of levels that are present in the data. E.g. if I filter to retain only 2 treatment categories - two facet plots should still look great. But it's doing like 10 plots (because the variable has this many levels).. the resulting plots are so flat that nothing can be seen.. could one smuggle in a "drop_unused_levels" or similar within the KM model (after applying the filters, before plotting)

@mthbretscher
Copy link

mthbretscher commented Dec 16, 2022

One way I could guess how one could solve this:
at this line in the code, replace nrow = seq_along(levels(anl$facet_var)) with something that drops unused levels from anl$facet_var first.. (not tested)

@mthbretscher
Copy link

As a temporary fix for myself I chose to override template_g_km template_g_km . This appears to be working reasonably well for a start (i.e. one can facet plot, just need to subset to a small number of categories at a time, and plots are still a bit flat). Faceting in a grid still worth considering.

@Melkiades Melkiades added the core label Feb 15, 2023
@chlebowa chlebowa self-assigned this Feb 15, 2023
chlebowa added a commit that referenced this issue Feb 21, 2023
Closes #665.

Added expression that drops unused levels of faceting variable before
plotting, so that empty panels are not plotted.

---------

Co-authored-by: Mahmoud Hallal <mahmoud.hallal@roche.com>
Co-authored-by: Mahmoud Hallal <86970066+mhallal1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request sme
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants