|
2 | 2 | from matplotlib.legend_handler import HandlerTuple |
3 | 3 |
|
4 | 4 | fig, (ax1, ax2) = plt.subplots(2, 1) |
5 | | -p1 = ax1.scatter([1],[5], c='r', marker='s', s=100) |
6 | | -p2 = ax1.scatter([3],[2], c='b', marker='o', s=100) |
| 5 | +p1 = ax1.scatter([1], [5], c='r', marker='s', s=100) |
| 6 | +p2 = ax1.scatter([3], [2], c='b', marker='o', s=100) |
7 | 7 |
|
8 | | -l = ax1.legend([(p1, p2)],['points'], scatterpoints=1, |
| 8 | +l = ax1.legend([(p1, p2)], ['points'], scatterpoints=1, |
9 | 9 | handler_map={tuple: HandlerTuple(ndivide=0)}) |
10 | 10 |
|
11 | | -ind = [1,2,3] |
| 11 | +ind = [1, 2, 3] |
12 | 12 | pos1 = [1, 3, 2] |
13 | 13 | neg1 = [2, 1, 4] |
14 | | -width=[0.5, 0.5, 0.5] |
| 14 | +width = [0.5, 0.5, 0.5] |
15 | 15 |
|
16 | 16 | rpos1 = ax2.bar(ind, pos1, width=0.5, color='k', label='+1') |
17 | 17 | rneg1 = ax2.bar(ind, neg1, width=0.5, color='w', hatch='///', label='-1') |
18 | 18 |
|
19 | | -l = ax2.legend([(rpos1, rneg1)],['Test'], |
| 19 | +l = ax2.legend([(rpos1, rneg1)], ['Test'], |
20 | 20 | handler_map={(rpos1, rneg1): HandlerTuple(ndivide=0, pad=0.)}) |
21 | 21 |
|
22 | 22 | plt.show() |
0 commit comments