Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd13065b

Browse files
authored
Merge pull request#24519 from oscargus/legendhandlermnt
MNT: remove unused arguments to private methods and minor doc fixes
2 parentsf1e5de1 +dad1c18 commitd13065b

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

‎lib/matplotlib/legend_handler.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
plot, *fontsize* is the fontsize in pixels, and *handlebox* is a
1818
OffsetBox instance. Within the call, you should create relevant
1919
artists (using relevant properties from the *legend* and/or
20-
*orig_handle*) and add them into the handlebox. The artistsneeds to
20+
*orig_handle*) and add them into the handlebox. The artistsneed to
2121
be scaled according to the fontsize (note that the size is in pixel,
2222
i.e., this is dpi-scaled value).
2323
@@ -46,7 +46,7 @@ def update_from_first_child(tgt, src):
4646

4747
classHandlerBase:
4848
"""
49-
ABase class for default legend handlers.
49+
Abase class for default legend handlers.
5050
5151
The derived classes are meant to override *create_artists* method, which
5252
has a following signature.::
@@ -319,7 +319,7 @@ def patch_func(legend=legend, orig_handle=orig_handle,
319319
xdescent=xdescent, ydescent=ydescent,
320320
width=width, height=height, fontsize=fontsize)
321321
322-
Subsequently the created artist will have its ``update_prop``
322+
Subsequently, the created artist will have its ``update_prop``
323323
method called and the appropriate transform will be applied.
324324
325325
**kwargs
@@ -353,37 +353,33 @@ class HandlerStepPatch(HandlerBase):
353353
Handler for `~.matplotlib.patches.StepPatch` instances.
354354
"""
355355

356-
def_create_patch(self,legend,orig_handle,
357-
xdescent,ydescent,width,height,fontsize):
358-
p=Rectangle(xy=(-xdescent,-ydescent),
359-
color=orig_handle.get_facecolor(),
360-
width=width,height=height)
361-
returnp
362-
363-
# Unfilled StepPatch should show as a line
364-
def_create_line(self,legend,orig_handle,
365-
xdescent,ydescent,width,height,fontsize):
356+
@staticmethod
357+
def_create_patch(orig_handle,xdescent,ydescent,width,height):
358+
returnRectangle(xy=(-xdescent,-ydescent),width=width,
359+
height=height,color=orig_handle.get_facecolor())
366360

367-
# Overwrite manually because patch and line properties don't mix
361+
@staticmethod
362+
def_create_line(orig_handle,width,height):
363+
# Unfilled StepPatch should show as a line
368364
legline=Line2D([0,width], [height/2,height/2],
369365
color=orig_handle.get_edgecolor(),
370366
linestyle=orig_handle.get_linestyle(),
371367
linewidth=orig_handle.get_linewidth(),
372368
)
373369

370+
# Overwrite manually because patch and line properties don't mix
374371
legline.set_drawstyle('default')
375372
legline.set_marker("")
376373
returnlegline
377374

378375
defcreate_artists(self,legend,orig_handle,
379376
xdescent,ydescent,width,height,fontsize,trans):
380377
iforig_handle.get_fill()or (orig_handle.get_hatch()isnotNone):
381-
p=self._create_patch(legend,orig_handle,
382-
xdescent,ydescent,width,height,fontsize)
378+
p=self._create_patch(orig_handle,xdescent,ydescent,width,
379+
height)
383380
self.update_prop(p,orig_handle,legend)
384381
else:
385-
p=self._create_line(legend,orig_handle,
386-
xdescent,ydescent,width,height,fontsize)
382+
p=self._create_line(orig_handle,width,height)
387383
p.set_transform(trans)
388384
return [p]
389385

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp