Skip to content

fix: avoid tiny facet panels when plotting many variables - #177

Merged
vrahier merged 1 commit into
mainfrom
vrahier/fix-ncol-wrap
Oct 8, 2026
Merged

vrahier merged 1 commit into
mainfrom
vrahier/fix-ncol-wrap

Conversation

@vrahier

@vrahier vrahier commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Since #162, add_facet_wrap() sets the number of facet columns with get_ncol(), which never returns more than 3 columns. Before, ggplot2 chose the layout itself (a near-square grid).

When there are many variables, the layout becomes very tall: 14 variables give 2 columns × 7 rows instead of a 4×4 grid. Scatter plots set aspect.ratio = 1, so the panel size is limited by the plot height and the panels come out tiny. This happens for example with plot_scat_versions_per_sit:

Changes:

  • get_ncol(): the 1/2/3-column rule still applies up to 6 facets. Above 6, it uses the ggplot2 default layout (ggplot2::wrap_dims()).
  • adjust_legend_position(): the legend goes to the bottom when there are 3 or more columns (ncol >= 3 instead of ncol == 3), since get_ncol() can now return more than 3.

Updated the roxygen docs and the .Rd files.

@vrahier vrahier self-assigned this Oct 8, 2026
@vrahier
vrahier merged commit 15d6306 into main Oct 8, 2026
10 of 11 checks passed
@vrahier
vrahier deleted the vrahier/fix-ncol-wrap branch October 8, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant