| 413 | ax.legend((lnc, lns), labels=('a', 'b')) |
| 414 | |
| 415 | def test_parasite(self): |
| 416 | from mpl_toolkits.axes_grid1 import host_subplot |
| 417 | |
| 418 | host = host_subplot(111) |
| 419 | par = host.twinx() |
| 420 | |
| 421 | p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density") |
| 422 | p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature") |
| 423 | |
| 424 | with mock.patch('matplotlib.legend.Legend') as Legend: |
| 425 | plt.legend() |
| 426 | Legend.assert_called_with(host, [p1, p2], ['Density', 'Temperature']) |
| 427 | |
| 428 | def test_legend_warns_on_unequal_number_of_handles_and_labels(self): |
| 429 | fig, ax = plt.subplots() |