From 8a1fd2ce88ee974828a14de0d20e58fec322233a Mon Sep 17 00:00:00 2001 From: Agustina Arroyuelo Date: Fri, 26 Mar 2021 11:27:50 -0300 Subject: [PATCH] Fix xlabels and ax argument in plot_elpd (#1601) * fix ax argument for numvars > 2 and xlabels * update changelog * fix xlabels --- CHANGELOG.md | 1 + arviz/plots/backends/matplotlib/elpdplot.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdacda7e0f..dfcb755962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ * Fix `from_numpyro` crash when importing model with `thinning=x` for `x > 1` ([1619](https://github.com/arviz-devs/arviz/pull/1619)) * Upload updated mypy.ini in ci if mypy copilot fails ([1624](https://github.com/arviz-devs/arviz/pull/1624)) * Added type checking to raise an error whenever `InferenceData` object is passed using `io_pymc3`'s `trace` argument ([1629](https://github.com/arviz-devs/arviz/pull/1629)) +* Fix `xlabels` in `plot_elpd` ([1601](https://github.com/arviz-devs/arviz/pull/1601)) ### Deprecation * Deprecated `index_origin` and `order` arguments in `az.summary` ([1201](https://github.com/arviz-devs/arviz/pull/1201)) diff --git a/arviz/plots/backends/matplotlib/elpdplot.py b/arviz/plots/backends/matplotlib/elpdplot.py index 08c878f235..969ad55b36 100644 --- a/arviz/plots/backends/matplotlib/elpdplot.py +++ b/arviz/plots/backends/matplotlib/elpdplot.py @@ -138,10 +138,10 @@ def plot_elpd( squeeze=False, constrained_layout=not xlabels, sharey="row", - sharex="all", + sharex="col", ) else: - fig = ax.get_figure() + fig = ax.ravel()[0].get_figure() for i in range(0, numvars - 1): var1 = pointwise_data[i] @@ -179,7 +179,8 @@ def plot_elpd( "{} - {}".format(models[i], models[j + 1]), fontsize=titlesize, wrap=True ) if xlabels: - set_xticklabels(ax[-1, -1], coord_labels) + for i in range(len(ax)): + set_xticklabels(ax[-1, i], coord_labels) fig.autofmt_xdate() fig.tight_layout() if legend: