From e0e971a198fc8d63e374cadef965d0198c3fdef0 Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Tue, 26 Nov 2024 12:15:55 +0300 Subject: [PATCH] Split legend with more than 15 keys into columns closes #757 --- doc/changelog.qmd | 5 +++++ plotnine/guides/guide_legend.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/changelog.qmd b/doc/changelog.qmd index 51bb0c9ee..7e4c59e8b 100644 --- a/doc/changelog.qmd +++ b/doc/changelog.qmd @@ -12,6 +12,11 @@ title: Changelog - When using [](:class:`~plotnine.geom_text`) with `adjust_text`, some sensible default arrow properties will be applied. +- Changed the threshold number of keys for when the legend is split into multiple + columns from 20 to 15. This only applies in the default case when the user does + not set the number of rows or columns i.e. `guide_legend(nrow=None, ncol=None). + ({{< issue 757 >}}) + ## v0.14.2 (2024-11-21) diff --git a/plotnine/guides/guide_legend.py b/plotnine/guides/guide_legend.py index 06d56cad9..d9aaada11 100644 --- a/plotnine/guides/guide_legend.py +++ b/plotnine/guides/guide_legend.py @@ -223,7 +223,7 @@ def _calculate_rows_and_cols( if elements.is_horizontal: nrow = int(np.ceil(nbreak / 5)) else: - ncol = int(np.ceil(nbreak / 20)) + ncol = int(np.ceil(nbreak / 15)) if nrow is None: ncol = cast(int, ncol)