Skip to content

Commit b1e9d78

Browse files
authored
Merge pull request matplotlib#30269 from meeseeksmachine/auto-backport-of-pr-30186-on-v3.10.x
Backport PR matplotlib#30186 on branch v3.10.x (Fix figure legend when drawing stackplots)
2 parents c7c1136 + 3c47b24 commit b1e9d78

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/legend_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ def get_first(prop_array):
800800
legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))
801801
legend_handle.set_linestyle(get_first(orig_handle.get_linestyles()))
802802
legend_handle.set_transform(get_first(orig_handle.get_transforms()))
803-
legend_handle.set_figure(orig_handle.get_figure())
804803
# Alpha is already taken into account by the color attributes.
805804

806805
def create_artists(self, legend, orig_handle,

lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,6 +3293,20 @@ def test_stackplot_hatching(fig_ref, fig_test):
32933293
ax_ref.set_ylim((0, 70))
32943294

32953295

3296+
def test_stackplot_subfig_legend():
3297+
# Smoke test for https://github.com/matplotlib/matplotlib/issues/30158
3298+
3299+
fig = plt.figure()
3300+
subfigs = fig.subfigures(nrows=1, ncols=2)
3301+
3302+
for _fig in subfigs:
3303+
ax = _fig.subplots(nrows=1, ncols=1)
3304+
ax.stackplot([3, 4], [[1, 2]], labels=['a'])
3305+
3306+
fig.legend()
3307+
fig.draw_without_rendering()
3308+
3309+
32963310
def _bxp_test_helper(
32973311
stats_kwargs={}, transform_stats=lambda s: s, bxp_kwargs={}):
32983312
np.random.seed(937)

0 commit comments

Comments
 (0)