8000 Adding corresponding What's new entry · matplotlib/matplotlib@b7fe34d · GitHub
[go: up one dir, main page]

Skip to content

Commit b7fe34d

Browse files
committed
Adding corresponding What's new entry
1 parent d7946fb commit b7fe34d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Subfigures have now controllable zorders
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Previously, setting the zorder of a subfigure had no effect, and those were plotted on top of any figure-level artists (i.e for example on top of fig-level legends). Now, subfigures behave like any other artists, and their zorder can be controlled, with default a zorder of 0.
5+
6+
.. plot::
7+
:include-source: true
8+
:alt: Example on controlling the zorder of a subfigure
9+
10+
import matplotlib.pyplot as plt
11+
import numpy as np
12+
x = np.linspace(1, 10, 10)
13+
y1, y2 = x, -x
14+
fig = plt.figure(constrained_layout=True)
15+
subfigs = fig.subfigures(nrows=1, ncols=2)
16+
for subfig in subfigs:
17+
axarr = subfig.subplots(2, 1)
18+
for ax in axarr.flatten():
19+
(l1,) = ax.plot(x, y1, label="line1")
20+
(l2,) = ax.plot(x, y2, label="line2")
21+
subfigs[0].set_zorder(6)
22+
l = fig.legend(handles=[l1, l2], loc="upper center", ncol=2)

0 commit comments

Comments
 (0)
0