|
38 | 38 | from matplotlib.font_manager import FontProperties |
39 | 39 | from matplotlib.lines import Line2D |
40 | 40 | from matplotlib.patches import Patch, Rectangle, Shadow, FancyBboxPatch |
41 | | -from matplotlib.collections import LineCollection, RegularPolyCollection, \ |
42 | | - CircleCollection, PathCollection, PolyCollection |
| 41 | +from matplotlib.collections import (LineCollection, RegularPolyCollection, |
| 42 | + CircleCollection, PathCollection, |
| 43 | + PolyCollection) |
43 | 44 | from matplotlib.transforms import Bbox, BboxBase, TransformedBbox |
44 | 45 | from matplotlib.transforms import BboxTransformTo, BboxTransformFrom |
45 | 46 |
|
@@ -93,7 +94,8 @@ def _update_loc(self, loc_in_canvas): |
93 | 94 |
|
94 | 95 | _bbox_transform = BboxTransformFrom(bbox) |
95 | 96 | self.legend._loc = tuple( |
96 | | - _bbox_transform.transform_point(loc_in_canvas)) |
| 97 | + _bbox_transform.transform_point(loc_in_canvas) |
| 98 | + ) |
97 | 99 |
|
98 | 100 | def _update_bbox_to_anchor(self, loc_in_canvas): |
99 | 101 |
|
@@ -178,7 +180,7 @@ def __init__(self, parent, handles, labels, |
178 | 180 | shadow=None, |
179 | 181 | title=None, # set a title for the legend |
180 | 182 |
|
181 | | - framealpha=None, # set frame alpha |
| 183 | + framealpha=None, # set frame alpha |
182 | 184 |
|
183 | 185 | bbox_to_anchor=None, # bbox that the legend will be anchored. |
184 | 186 | bbox_transform=None, # transform for the bbox |
@@ -320,13 +322,15 @@ def __init__(self, parent, handles, labels, |
320 | 322 | if self.isaxes: |
321 | 323 | warnings.warn('Unrecognized location "%s". Falling back ' |
322 | 324 | 'on "best"; valid locations are\n\t%s\n' |
323 | | - % (loc, '\n\t'.join(six.iterkeys(self.codes)))) |
| 325 | + % (loc, '\n\t'.join( |
| 326 | + six.iterkeys(self.codes)))) |
324 | 327 | loc = 0 |
325 | 328 | else: |
326 | 329 | warnings.warn('Unrecognized location "%s". Falling back ' |
327 | 330 | 'on "upper right"; ' |
328 | 331 | 'valid locations are\n\t%s\n' |
329 | | - % (loc, '\n\t'.join(six.iterkeys(self.codes)))) |
| 332 | + % (loc, '\n\t'.join( |
| 333 | + six.iterkeys(self.codes)))) |
330 | 334 | loc = 1 |
331 | 335 | else: |
332 | 336 | loc = self.codes[loc] |
@@ -400,8 +404,8 @@ def _set_loc(self, loc): |
400 | 404 | else: |
401 | 405 | _findoffset = self._findoffset_loc |
402 | 406 |
|
403 | | - #def findoffset(width, height, xdescent, ydescent): |
404 | | - # return _findoffset(width, height, xdescent, ydescent, renderer) |
| 407 | +# def findoffset(width, height, xdescent, ydescent): |
| 408 | +# return _findoffset(width, height, xdescent, ydescent, renderer) |
405 | 409 |
|
406 | 410 | self._legend_box.set_offset(_findoffset) |
407 | 411 |
|
@@ -489,7 +493,7 @@ def _approx_text_height(self, renderer=None): |
489 | 493 | RegularPolyCollection: legend_handler.HandlerRegularPolyCollection(), |
490 | 494 | CircleCollection: legend_handler.HandlerCircleCollection(), |
491 | 495 | BarContainer: legend_handler.HandlerPatch( |
492 | | - update_func=legend_handler.update_from_first_child), |
| 496 | + update_func=legend_handler.update_from_first_child), |
493 | 497 | tuple: legend_handler.HandlerTuple(), |
494 | 498 | PathCollection: legend_handler.HandlerPathCollection(), |
495 | 499 | PolyCollection: legend_handler.HandlerPolyCollection() |
@@ -610,10 +614,11 @@ def _init_legend_box(self, handles, labels, markerfirst=True): |
610 | 614 | handler = self.get_legend_handler(legend_handler_map, orig_handle) |
611 | 615 | if handler is None: |
612 | 616 | warnings.warn( |
613 | | - "Legend does not support {!r} instances.\nA proxy artist " |
614 | | - "may be used instead.\nSee: " |
615 | | - "http://matplotlib.org/users/legend_guide.html" |
616 | | - "#using-proxy-artist".format(orig_handle)) |
| 617 | + "Legend does not support {!r} instances.\nA proxy artist " |
| 618 | + "may be used instead.\nSee: " |
| 619 | + "http://matplotlib.org/users/legend_guide.html" |
| 620 | + "#using-proxy-artist".format(orig_handle) |
| 621 | + ) |
617 | 622 | # We don't have a handle for this artist, so we just defer |
618 | 623 | # to None. |
619 | 624 | handle_list.append(None) |
@@ -658,11 +663,10 @@ def _init_legend_box(self, handles, labels, markerfirst=True): |
658 | 663 | # starting index of each column and number of rows in it. |
659 | 664 | largecol = safezip(list(xrange(0, |
660 | 665 | num_largecol * (nrows + 1), |
661 | | - (nrows + 1))), |
| 666 | + (nrows + 1))), |
662 | 667 | [nrows + 1] * num_largecol) |
663 | 668 | smallcol = safezip(list(xrange(num_largecol * (nrows + 1), |
664 | | - len(handleboxes), |
665 | | - nrows)), |
| 669 | + len(handleboxes), nrows)), |
666 | 670 | [nrows] * num_smallcol) |
667 | 671 | else: |
668 | 672 | largecol, smallcol = [], [] |
@@ -920,7 +924,7 @@ def _find_best_position(self, width, height, renderer, consider=None): |
920 | 924 | renderer) |
921 | 925 | for x in range(1, len(self.codes))] |
922 | 926 |
|
923 | | - #tx, ty = self.legendPatch.get_x(), self.legendPatch.get_y() |
| 927 | +# tx, ty = self.legendPatch.get_x(), self.legendPatch.get_y() |
924 | 928 |
|
925 | 929 | candidates = [] |
926 | 930 | for l, b in consider: |
|
0 commit comments