8000 Merge pull request #30186 from dstansby/fig-legend-error · matplotlib/matplotlib@99b4ee3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99b4ee3

Browse files
authored
Merge pull request #30186 from dstansby/fig-legend-error
Fix figure legend when drawing stackplots
2 parents 947590d + b370e30 commit 99b4ee3

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
@@ -799,7 +799,6 @@ def get_first(prop_array):
799799
legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))
800800
legend_handle.set_linestyle(get_first(orig_handle.get_linestyles()))
801801
legend_handle.set_transform(get_first(orig_handle.get_transforms()))
802-
legend_handle.set_figure(orig_handle.get_figure())
803802
# Alpha is already taken into account by the color attributes.
804803

805804
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
@@ -3420,6 +3420,20 @@ def test_stackplot_hatching(fig_ref, fig_test):
34203420
ax_ref.set_ylim(0, 70)
34213421

34223422

3423+
def test_stackplot_subfig_legend():
3424+
# Smoke test for https://github.com/matplotlib/matplotlib/issues/30158
3425+
3426+
fig = plt.figure()
3427+
subfigs = fig.subfigures(nrows=1, ncols=2)
3428+
3429+
for _fig in subfigs:
3430+
ax = _fig.subplots(nrows=1, ncols=1)
3431+
ax.stackplot([3, 4], [[1, 2]], labels=['a'])
3432+
3433+
fig.legend()
3434+
fig.draw_without_rendering()
3435+
3436+
34233437
def _bxp_test_helper(
34243438
stats_kwargs={}, transform_stats=lambda s: s, bxp_kwargs={}):
34253439
np.random.seed(937)

0 commit comments

Comments
 (0)
0