Skip to content

Commit a024ca5

Browse files
committed
STY: pep8 fixes to legend
1 parent 296acb4 commit a024ca5

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

lib/matplotlib/axes/_axes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ def legend(self, *args, **kwargs):
362362
363363
*markerfirst*: [ *True* | *False* ]
364364
if *True*, legend marker is placed to the left of the legend label
365-
if *False*, legend marker is placed to the right of the legend label
365+
if *False*, legend marker is placed to the right of the legend
366+
label
366367
367368
frameon : None or bool
368369
Control whether a frame should be drawn around the legend.

lib/matplotlib/figure.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,8 @@ def legend(self, handles, labels, *args, **kwargs):
11501150
11511151
*markerfirst*: [ *True* | *False* ]
11521152
if *True*, legend marker is placed to the left of the legend label
1153-
if *False*, legend marker is placed to the right of the legend label
1153+
if *False*, legend marker is placed to the right of the legend
1154+
label
11541155
11551156
*fancybox*: [ *None* | *False* | *True* ]
11561157
if *True*, draw a frame with a round fancybox. If *None*, use rc

lib/matplotlib/legend.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
from matplotlib.font_manager import FontProperties
3939
from matplotlib.lines import Line2D
4040
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)
4344
from matplotlib.transforms import Bbox, BboxBase, TransformedBbox
4445
from matplotlib.transforms import BboxTransformTo, BboxTransformFrom
4546

@@ -93,7 +94,8 @@ def _update_loc(self, loc_in_canvas):
9394

9495
_bbox_transform = BboxTransformFrom(bbox)
9596
self.legend._loc = tuple(
96-
_bbox_transform.transform_point(loc_in_canvas))
97+
_bbox_transform.transform_point(loc_in_canvas)
98+
)
9799

98100
def _update_bbox_to_anchor(self, loc_in_canvas):
99101

@@ -178,7 +180,7 @@ def __init__(self, parent, handles, labels,
178180
shadow=None,
179181
title=None, # set a title for the legend
180182

181-
framealpha=None, # set frame alpha
183+
framealpha=None, # set frame alpha
182184

183185
bbox_to_anchor=None, # bbox that the legend will be anchored.
184186
bbox_transform=None, # transform for the bbox
@@ -320,13 +322,15 @@ def __init__(self, parent, handles, labels,
320322
if self.isaxes:
321323
warnings.warn('Unrecognized location "%s". Falling back '
322324
'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))))
324327
loc = 0
325328
else:
326329
warnings.warn('Unrecognized location "%s". Falling back '
327330
'on "upper right"; '
328331
'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))))
330334
loc = 1
331335
else:
332336
loc = self.codes[loc]
@@ -400,8 +404,8 @@ def _set_loc(self, loc):
400404
else:
401405
_findoffset = self._findoffset_loc
402406

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)
405409

406410
self._legend_box.set_offset(_findoffset)
407411

@@ -489,7 +493,7 @@ def _approx_text_height(self, renderer=None):
489493
RegularPolyCollection: legend_handler.HandlerRegularPolyCollection(),
490494
CircleCollection: legend_handler.HandlerCircleCollection(),
491495
BarContainer: legend_handler.HandlerPatch(
492-
update_func=legend_handler.update_from_first_child),
496+
update_func=legend_handler.update_from_first_child),
493497
tuple: legend_handler.HandlerTuple(),
494498
PathCollection: legend_handler.HandlerPathCollection(),
495499
PolyCollection: legend_handler.HandlerPolyCollection()
@@ -610,10 +614,11 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
610614
handler = self.get_legend_handler(legend_handler_map, orig_handle)
611615
if handler is None:
612616
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+
)
617622
# We don't have a handle for this artist, so we just defer
618623
# to None.
619624
handle_list.append(None)
@@ -658,11 +663,10 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
658663
# starting index of each column and number of rows in it.
659664
largecol = safezip(list(xrange(0,
660665
num_largecol * (nrows + 1),
661-
(nrows + 1))),
666+
(nrows + 1))),
662667
[nrows + 1] * num_largecol)
663668
smallcol = safezip(list(xrange(num_largecol * (nrows + 1),
664-
len(handleboxes),
665-
nrows)),
669+
len(handleboxes), nrows)),
666670
[nrows] * num_smallcol)
667671
else:
668672
largecol, smallcol = [], []
@@ -920,7 +924,7 @@ def _find_best_position(self, width, height, renderer, consider=None):
920924
renderer)
921925
for x in range(1, len(self.codes))]
922926

923-
#tx, ty = self.legendPatch.get_x(), self.legendPatch.get_y()
927+
# tx, ty = self.legendPatch.get_x(), self.legendPatch.get_y()
924928

925929
candidates = []
926930
for l, b in consider:

0 commit comments

Comments
 (0)