diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ab834f8da..279e3f4f21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Maintenance and fixes +- Fix legend overwriting issue in `plot_trace` ([2334](https://github.com/arviz-devs/arviz/pull/2334)) + ### Deprecation ### Documentation diff --git a/arviz/plots/backends/matplotlib/traceplot.py b/arviz/plots/backends/matplotlib/traceplot.py index 71b4da731e..b00baa5daa 100644 --- a/arviz/plots/backends/matplotlib/traceplot.py +++ b/arviz/plots/backends/matplotlib/traceplot.py @@ -440,7 +440,7 @@ def plot_trace( [], [], label="combined", **dealiase_sel_kwargs(plot_kwargs, chain_prop, -1) ), ) - ax.figure.axes[0].legend(handles=handles, title="chain", loc="upper right") + ax.figure.axes[1].legend(handles=handles, title="chain", loc="upper right") if axes is None: axes = np.array(ax.figure.axes).reshape(-1, 2) diff --git a/arviz/tests/base_tests/test_plots_matplotlib.py b/arviz/tests/base_tests/test_plots_matplotlib.py index 8b56ed2138..2969ed100a 100644 --- a/arviz/tests/base_tests/test_plots_matplotlib.py +++ b/arviz/tests/base_tests/test_plots_matplotlib.py @@ -261,7 +261,7 @@ def test_plot_trace_legend(compact, combined): axes = plot_trace( idata, var_names=["home", "atts_star"], compact=compact, combined=combined, legend=True ) - assert axes[0, 0].get_legend() + assert axes[0, 1].get_legend() compact_legend = axes[1, 0].get_legend() if compact: assert axes.shape == (2, 2) diff --git a/doc/source/conf.py b/doc/source/conf.py index 9601b99fe4..71fa5d223d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -99,7 +99,18 @@ autodoc_typehints = "none" numpydoc_xref_param_type = True numpydoc_xref_ignore = { - "of", "or", "optional", "default", "1D", "2D", "3D", "n-dimensional", "K", "M", "N", "S", + "of", + "or", + "optional", + "default", + "1D", + "2D", + "3D", + "n-dimensional", + "K", + "M", + "N", + "S", } numpydoc_xref_aliases = { "DataArray": ":class:`~xarray.DataArray`", diff --git a/doc/sphinxext/gallery_generator.py b/doc/sphinxext/gallery_generator.py index c850c82af8..d06e6b53a8 100644 --- a/doc/sphinxext/gallery_generator.py +++ b/doc/sphinxext/gallery_generator.py @@ -5,6 +5,7 @@ Also inspired in bokeh's bokeh_gallery sphinxext. """ + import glob import os import os.path as op @@ -222,7 +223,7 @@ def overlay_description(self): elif self.apitext != "": return "{title} using `{apitext}`".format(title=self.title, apitext=self.apitext) return self.title - + @property def alt_text(self): if self._alt_text != "":