Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41eb1bc

Browse files
phobsontimhoffm
authored andcommitted
Backport PR #16080: Cleanup docstrings in backend_bases.py
1 parent 43ec193 commit 41eb1bc

File tree

1 file changed

+46
-51
lines changed

1 file changed

+46
-51
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def register_backend(format, backend, description=None):
104104
backend : module string or canvas class
105105
Backend for handling file output
106106
107-
description : str, optional
108-
Description of the file type. Defaults to an empty string
107+
description : str, default: ""
108+
Description of the file type.
109109
"""
110110
if description is None:
111111
description = ''
@@ -461,14 +461,14 @@ def draw_image(self, gc, x, y, im, transform=None):
461461
Parameters
462462
----------
463463
gc : `GraphicsContextBase`
464-
a graphics context with clipping information.
464+
A graphics context with clipping information.
465465
466466
x : scalar
467-
the distance in physical units (i.e., dots or pixels) from the left
467+
The distance in physical units (i.e., dots or pixels) from the left
468468
hand side of the canvas.
469469
470470
y : scalar
471-
the distance in physical units (i.e., dots or pixels) from the
471+
The distance in physical units (i.e., dots or pixels) from the
472472
bottom side of the canvas.
473473
474474
im : array-like, shape=(N, M, 4), dtype=np.uint8
@@ -517,22 +517,22 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
517517
----------
518518
gc : `GraphicsContextBase`
519519
The graphics context.
520-
x : scalar
520+
x : float
521521
The x location of the text in display coords.
522-
y : scalar
522+
y : float
523523
The y location of the text baseline in display coords.
524524
s : str
525525
The text string.
526526
prop : `matplotlib.font_manager.FontProperties`
527527
The font properties.
528-
angle : scalar
529-
The rotation angle in degrees.
528+
angle : float
529+
The rotation angle in degrees anti-clockwise.
530530
mtext : `matplotlib.text.Text`
531531
The original text object to be rendered.
532532
533533
Notes
534534
-----
535-
**backend implementers note**
535+
**Note for backend implementers:**
536536
537537
When you are trying to determine if you have gotten your bounding box
538538
right (which is what enables the text layout/alignment to work
@@ -664,11 +664,11 @@ def points_to_pixels(self, points):
664664
doesn't have a dpi, e.g., postscript or svg). Some imaging
665665
systems assume some value for pixels per inch::
666666
667-
points to pixels = points * pixels_per_inch/72.0 * dpi/72.0
667+
points to pixels = points * pixels_per_inch/72 * dpi/72
668668
669669
Parameters
670670
----------
671-
points : scalar or array-like
671+
points : float or array-like
672672
a float or a numpy array of float
673673
674674
Returns
@@ -1022,11 +1022,10 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
10221022
The amplitude of the wiggle perpendicular to the source line, in
10231023
pixels. If scale is `None`, or not provided, no sketch filter will
10241024
be provided.
1025-
length : float, optional
1026-
The length of the wiggle along the line, in pixels (default 128).
1027-
randomness : float, optional
1028-
The scale factor by which the length is shrunken or expanded
1029-
(default 16).
1025+
length : float, default: 128
1026+
The length of the wiggle along the line, in pixels.
1027+
randomness : float, default: 16
1028+
The scale factor by which the length is shrunken or expanded.
10301029
"""
10311030
self._sketch = (
10321031
None if scale is None
@@ -1259,12 +1258,10 @@ class ResizeEvent(Event):
12591258
12601259
Attributes
12611260
----------
1262-
width : scalar
1263-
width of the canvas in pixels
1264-
1265-
height : scalar
1266-
height of the canvas in pixels
1267-
1261+
width : int
1262+
Width of the canvas in pixels.
1263+
height : int
1264+
Height of the canvas in pixels.
12681265
"""
12691266
def __init__(self, name, canvas):
12701267
Event.__init__(self, name, canvas)
@@ -1287,20 +1284,16 @@ class LocationEvent(Event):
12871284
12881285
Attributes
12891286
----------
1290-
x : scalar
1291-
x position - pixels from left of canvas
1292-
1293-
y : scalar
1294-
y position - pixels from bottom of canvas
1295-
1296-
inaxes : bool
1297-
the :class:`~matplotlib.axes.Axes` instance if mouse is over axes
1298-
1299-
xdata : scalar
1300-
x coord of mouse in data coords
1301-
1302-
ydata : scalar
1303-
y coord of mouse in data coords
1287+
x : int
1288+
x position - pixels from left of canvas.
1289+
y : int
1290+
y position - pixels from bottom of canvas.
1291+
inaxes : `~.axes.Axes` or None
1292+
The `~.axes.Axes` instance over which the mouse is, if any.
1293+
xdata : float or None
1294+
x data coordinate of the mouse.
1295+
ydata : float or None
1296+
y data coordinate of the mouse.
13041297
"""
13051298

13061299
lastevent = None # the last event that was triggered before this one
@@ -1402,7 +1395,7 @@ class MouseEvent(LocationEvent):
14021395
The key pressed when the mouse event triggered, e.g. 'shift'.
14031396
See `KeyEvent`.
14041397
1405-
step : scalar
1398+
step : int
14061399
The number of scroll steps (positive for 'up', negative for 'down').
14071400
This applies only to 'scroll_event' and defaults to 0 otherwise.
14081401
@@ -1989,29 +1982,31 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
19891982
filename
19901983
can also be a file object on image backends
19911984
1992-
orientation : {'landscape', 'portrait'}, optional
1985+
orientation : {'landscape', 'portrait'}, default: 'portrait'
19931986
only currently applies to PostScript printing.
19941987
19951988
dpi : scalar, optional
19961989
the dots per inch to save the figure in; if None, use savefig.dpi
19971990
1998-
facecolor : color or None, optional
1999-
the facecolor of the figure; if None, defaults to savefig.facecolor
1991+
facecolor : color, default: :rc:`savefig.facecolor`
1992+
The facecolor of the figure.
20001993
2001-
edgecolor : color or None, optional
2002-
the edgecolor of the figure; if None, defaults to savefig.edgecolor
1994+
edgecolor : color, default: :rc:`savefig.edgecolor`
1995+
The edgecolor of the figure.
20031996
20041997
format : str, optional
2005-
when set, forcibly set the file format to save to
1998+
Force a specific file format. If not given, the format is inferred
1999+
from the *filename* extension, and if that fails from
2000+
:rc:`savefig.format`.
20062001
2007-
bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
2002+
bbox_inches : 'tight' or `~matplotlib.transforms.Bbox`, \
2003+
default: :rc:`savefig.bbox`
20082004
Bbox in inches. Only the given portion of the figure is
20092005
saved. If 'tight', try to figure out the tight bbox of
2010-
the figure. If None, use savefig.bbox
2006+
the figure.
20112007
2012-
pad_inches : scalar, optional
2013-
Amount of padding around the figure when bbox_inches is
2014-
'tight'. If None, use savefig.pad_inches
2008+
pad_inches : float, default: :rc:`savefig.pad_inches`
2009+
Amount of padding around the figure when *bbox_inches* is 'tight'.
20152010
20162011
bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional
20172012
A list of extra artists that will be considered when the
@@ -3400,9 +3395,9 @@ def mainloop(self):
34003395

34013396
class ShowBase(_Backend):
34023397
"""
3403-
Simple base class to generate a show() callable in backends.
3398+
Simple base class to generate a ``show()`` function in backends.
34043399
3405-
Subclass must override mainloop() method.
3400+
Subclass must override ``mainloop()`` method.
34063401
"""
34073402

34083403
def __call__(self, block=None):

0 commit comments

Comments
 (0)