Skip to content

Commit 935976c

Browse files
committed
Cleanup parasite_simple example.
- Use `legend(labelcolor=...)` instead of setting colors manually. - Use `ax.legend` instead of `plt.legend`. - Order imports.
1 parent bf9a451 commit 935976c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

examples/axes_grid1/parasite_simple.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
===============
33
Parasite Simple
44
===============
5-
65
"""
7-
from mpl_toolkits.axes_grid1 import host_subplot
6+
87
import matplotlib.pyplot as plt
8+
from mpl_toolkits.axes_grid1 import host_subplot
99

1010
host = host_subplot(111)
11-
1211
par = host.twinx()
1312

1413
host.set_xlabel("Distance")
@@ -18,12 +17,9 @@
1817
p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
1918
p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature")
2019

21-
leg = plt.legend()
20+
host.legend(labelcolor="linecolor")
2221

2322
host.yaxis.get_label().set_color(p1.get_color())
24-
leg.texts[0].set_color(p1.get_color())
25-
2623
par.yaxis.get_label().set_color(p2.get_color())
27-
leg.texts[1].set_color(p2.get_color())
2824

2925
plt.show()

0 commit comments

Comments
 (0)