Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d213621

Browse files
authored
Merge pull request #10983 from timhoffm/zorder-demo
Simplfy zorder_demo example for individual order
2 parents e2a0813 + a4f0ad5 commit d213621

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

examples/misc/zorder_demo.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,13 @@
5656
# A new figure, with individually ordered items
5757

5858
x = np.linspace(0, 2*np.pi, 100)
59+
plt.rcParams['lines.linewidth'] = 10
5960
plt.figure()
60-
plt.plot(x, np.sin(x), linewidth=10, label='zorder=10',
61-
zorder=10) # on top
62-
plt.plot(x, np.cos(1.3*x), linewidth=10, label='zorder=1',
63-
zorder=1) # bottom
64-
plt.plot(x, np.sin(2.1*x), linewidth=10, label='zorder=3',
65-
zorder=3)
66-
plt.axhline(0, linewidth=10, label='zorder=2',
67-
zorder=2)
61+
plt.plot(x, np.sin(x), label='zorder=10', zorder=10) # on top
62+
plt.plot(x, np.sin(1.1*x), label='zorder=1', zorder=1) # bottom
63+
plt.plot(x, np.sin(1.2*x), label='zorder=3', zorder=3)
64+
plt.axhline(0, label='zorder=2', color='grey', zorder=2)
6865
plt.title('Custom order of elements')
69-
l = plt.legend()
66+
l = plt.legend(loc='upper right')
7067
l.set_zorder(20) # put the legend on top
7168
plt.show()

0 commit comments

Comments
 (0)