From 262c311c573ba49a31425ad80361a45c86cf233c Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Sun, 31 Dec 2023 11:56:19 +1100 Subject: [PATCH] Call align_ylabels on subset plots (#266) --- CHANGELOG.rst | 1 + upsetplot/plotting.py | 46 ++++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 37a37ef..728d0cd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ What's new in version 0.9 - Fixes a bug where ``show_percentages`` used the incorrect denominator if filtering (e.g. ``min_subset_size``) was applied. This bug was a regression introduced in version 0.7. (:issue:`248`) +- Align ylabels of subplots added using ``add_catplot``. (:issue:`266`) - Add a ``style_categories`` method to customize category plot styles, including shading of rows in the intersection matrix, and bars in the totals plot. (:issue:`261` with thanks to :user:`Marcel Albus `). diff --git a/upsetplot/plotting.py b/upsetplot/plotting.py index 8b99712..c69636b 100644 --- a/upsetplot/plotting.py +++ b/upsetplot/plotting.py @@ -104,34 +104,36 @@ def __call__(self, *args, **kwargs): ) _NAME_TRANSPOSE = { - "width": "height", - "height": "width", - "hspace": "wspace", - "wspace": "hspace", - "hlines": "vlines", - "vlines": "hlines", + "align_xlabels": "align_ylabels", + "align_ylabels": "align_xlabels", "bar": "barh", "barh": "bar", - "xaxis": "yaxis", - "yaxis": "xaxis", - "left": "bottom", - "right": "top", - "top": "right", "bottom": "left", - "sharex": "sharey", - "sharey": "sharex", - "get_figwidth": "get_figheight", "get_figheight": "get_figwidth", - "set_figwidth": "set_figheight", - "set_figheight": "set_figwidth", - "set_xlabel": "set_ylabel", - "set_ylabel": "set_xlabel", - "set_xlim": "set_ylim", - "set_ylim": "set_xlim", + "get_figwidth": "get_figheight", "get_xlim": "get_ylim", "get_ylim": "get_xlim", + "height": "width", + "hlines": "vlines", + "hspace": "wspace", + "left": "bottom", + "right": "top", "set_autoscalex_on": "set_autoscaley_on", "set_autoscaley_on": "set_autoscalex_on", + "set_figheight": "set_figwidth", + "set_figwidth": "set_figheight", + "set_xlabel": "set_ylabel", + "set_xlim": "set_ylim", + "set_ylabel": "set_xlabel", + "set_ylim": "set_xlim", + "sharex": "sharey", + "sharey": "sharex", + "top": "right", + "vlines": "hlines", + "width": "height", + "wspace": "hspace", + "xaxis": "yaxis", + "yaxis": "xaxis", } @@ -1116,6 +1118,10 @@ def plot(self, fig=None): else: raise ValueError("Unknown subset plot type: %r" % plot["type"]) out[plot["id"]] = ax + + self._reorient(fig).align_ylabels( + [out[plot["id"]] for plot in self._subset_plots] + ) return out PLOT_TYPES = {