Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed plot_trace legend overwriting by chain legend (Issue #2320) #2334

Merged
merged 9 commits into from
Apr 8, 2024
4 changes: 2 additions & 2 deletions arviz/plots/backends/matplotlib/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ 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)

Expand Down
2 changes: 1 addition & 1 deletion arviz/tests/base_tests/test_plots_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading