@@ -70,7 +70,7 @@ def composite_images(images, renderer, magnification=1.0):
70
70
71
71
renderer : `.RendererBase`
72
72
73
- magnification : float
73
+ magnification : float, default: 1
74
74
The additional magnification to apply for the renderer in use.
75
75
76
76
Returns
@@ -303,8 +303,7 @@ def _get_scalar_alpha(self):
303
303
304
304
def changed (self ):
305
305
"""
306
- Call this whenever the mappable is changed so observers can
307
- update state
306
+ Call this whenever the mappable is changed so observers can update.
308
307
"""
309
308
self ._imcache = None
310
309
self ._rgbacache = None
@@ -627,9 +626,7 @@ def draw(self, renderer, *args, **kwargs):
627
626
self .stale = False
628
627
629
628
def contains (self , mouseevent ):
630
- """
631
- Test whether the mouse event occurred within the image.
632
- """
629
+ """Test whether the mouse event occurred within the image."""
633
630
inside , info = self ._default_contains (mouseevent )
634
631
if inside is not None :
635
632
return inside , info
@@ -659,7 +656,7 @@ def contains(self, mouseevent):
659
656
return inside , {}
660
657
661
658
def write_png (self , fname ):
662
- """Write the image to png file with fname"""
659
+ """Write the image to png file * fname*. """
663
660
im = self .to_rgba (self ._A [::- 1 ] if self .origin == 'lower' else self ._A ,
664
661
bytes = True , norm = True )
665
662
PIL .Image .fromarray (im ).save (fname , format = "png" )
@@ -733,15 +730,14 @@ def get_interpolation(self):
733
730
'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',
734
731
'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos',
735
732
or 'none'.
736
-
737
733
"""
738
734
return self ._interpolation
739
735
740
736
def set_interpolation (self , s ):
741
737
"""
742
738
Set the interpolation method the image uses when resizing.
743
739
744
- if None, use a value from rc setting . If 'none', the image is
740
+ If None, use :rc:`image.interpolation` . If 'none', the image is
745
741
shown as is without interpolating. 'none' is only supported in
746
742
agg, ps and pdf backends and will fall back to 'nearest' mode
747
743
for other backends.
@@ -750,8 +746,7 @@ def set_interpolation(self, s):
750
746
----------
751
747
s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16',
752
748
'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', \
753
- 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'}
754
-
749
+ 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
755
750
"""
756
751
if s is None :
757
752
s = rcParams ['image.interpolation' ]
@@ -775,7 +770,7 @@ def set_resample(self, v):
775
770
Parameters
776
771
----------
777
772
v : bool or None
778
- If None, use :rc:`image.resample` = True .
773
+ If None, use :rc:`image.resample`.
779
774
"""
780
775
if v is None :
781
776
v = rcParams ['image.resample' ]
@@ -862,7 +857,6 @@ class AxesImage(_ImageBase):
862
857
When True, use a full resampling method. When False, only resample when
863
858
the output image is larger than the input image.
864
859
**kwargs : `.Artist` properties
865
-
866
860
"""
867
861
def __str__ (self ):
868
862
return "AxesImage(%g,%g;%gx%g)" % tuple (self .axes .bbox .bounds )
@@ -911,9 +905,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
911
905
magnification , unsampled = unsampled )
912
906
913
907
def _check_unsampled_image (self , renderer ):
914
- """
915
- Return whether the image would be better drawn unsampled.
916
- """
908
+ """Return whether the image would be better drawn unsampled."""
917
909
return (self .get_interpolation () == "none"
918
910
and renderer .option_scale_image ())
919
911
@@ -999,7 +991,7 @@ def __init__(self, ax, *, interpolation='nearest', **kwargs):
999
991
"""
1000
992
Parameters
1001
993
----------
1002
- interpolation : {'nearest', 'bilinear'}
994
+ interpolation : {'nearest', 'bilinear'}, default: 'nearest'
1003
995
1004
996
**kwargs
1005
997
All other keyword arguments are identical to those of `.AxesImage`.
@@ -1091,8 +1083,8 @@ def set_interpolation(self, s):
1091
1083
"""
1092
1084
Parameters
1093
1085
----------
1094
- s : str, None
1095
- Either 'nearest', 'bilinear', or ``None` `.
1086
+ s : {'nearest', 'bilinear'} or None
1087
+ If None, use :rc:`image.interpolation `.
1096
1088
"""
1097
1089
if s is not None and s not in ('nearest' , 'bilinear' ):
1098
1090
raise NotImplementedError ('Only nearest neighbor and '
@@ -1137,12 +1129,28 @@ def __init__(self, ax,
1137
1129
** kwargs
1138
1130
):
1139
1131
"""
1140
- cmap defaults to its rc setting
1141
-
1142
- cmap is a colors.Colormap instance
1143
- norm is a colors.Normalize instance to map luminance to 0-1
1144
-
1145
- Additional kwargs are matplotlib.artist properties
1132
+ Parameters
1133
+ ----------
1134
+ ax : `~.axes.Axes`
1135
+ The axes the image will belong to.
1136
+ x, y : 1D array-like, optional
1137
+ Monotonic arrays of length N+1 and M+1, respectively, specifying
1138
+ rectangle boundaries. If not given, will default to
1139
+ ``range(N + 1)`` and ``range(M + 1)``, respectively.
1140
+ A : array-like
1141
+ The data to be color-coded. The interpretation depends on the
1142
+ shape:
1143
+
1144
+ - (M, N) ndarray or masked array: values to be colormapped
1145
+ - (M, N, 3): RGB array
1146
+ - (M, N, 4): RGBA array
1147
+
1148
+ cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
1149
+ The Colormap instance or registered colormap name used to map
1150
+ scalar data to colors.
1151
+ norm : `~matplotlib.colors.Normalize`
1152
+ Maps luminance to 0-1.
1153
+ **kwargs : `.Artist` properties
1146
1154
"""
1147
1155
super ().__init__ (ax , norm = norm , cmap = cmap )
1148
1156
self .update (kwargs )
@@ -1192,13 +1200,17 @@ def set_data(self, x, y, A):
1192
1200
1193
1201
Parameters
1194
1202
----------
1195
- x, y : 1D array-likes or None
1196
- Monotonic arrays of shapes (N + 1,) and (M + 1,), respectively,
1197
- specifying rectangle boundaries. If None , will default to
1203
+ x, y : 1D array-like, optional
1204
+ Monotonic arrays of length N+1 and M+1, respectively, specifying
1205
+ rectangle boundaries. If not given , will default to
1198
1206
``range(N + 1)`` and ``range(M + 1)``, respectively.
1199
1207
A : array-like
1200
- (M, N) ndarray or masked array of values to be colormapped, or
1201
- (M, N, 3) RGB array, or (M, N, 4) RGBA array.
1208
+ The data to be color-coded. The interpretation depends on the
1209
+ shape:
1210
+
1211
+ - (M, N) ndarray or masked array: values to be colormapped
1212
+ - (M, N, 3): RGB array
1213
+ - (M, N, 4): RGBA array
1202
1214
"""
1203
1215
A = cbook .safe_masked_invalid (A , copy = True )
1204
1216
if x is None :
@@ -1473,17 +1485,15 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
1473
1485
values that map to the colormap color limits. If either *vmin*
1474
1486
or *vmax* is None, that limit is determined from the *arr*
1475
1487
min/max value.
1476
- cmap : str or `~matplotlib.colors.Colormap`, optional
1488
+ cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
1477
1489
A Colormap instance or registered colormap name. The colormap
1478
1490
maps scalar data to colors. It is ignored for RGB(A) data.
1479
- Defaults to :rc:`image.cmap` ('viridis').
1480
1491
format : str, optional
1481
1492
The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when this
1482
1493
is unset is documented under *fname*.
1483
- origin : {'upper', 'lower'}, optional
1494
+ origin : {'upper', 'lower'}, default: :rc:`image.origin`
1484
1495
Indicates whether the ``(0, 0)`` index of the array is in the upper
1485
- left or lower left corner of the axes. Defaults to :rc:`image.origin`
1486
- ('upper').
1496
+ left or lower left corner of the axes.
1487
1497
dpi : int
1488
1498
The DPI to store in the metadata of the file. This does not affect the
1489
1499
resolution of the output image.
@@ -1547,7 +1557,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
1547
1557
1548
1558
1549
1559
def pil_to_array (pilImage ):
1550
- """Load a `PIL image`_ and return it as a numpy int array.
1560
+ """
1561
+ Load a `PIL image`_ and return it as a numpy int array.
1551
1562
1552
1563
.. _PIL image: https://pillow.readthedocs.io/en/latest/reference/Image.html
1553
1564
@@ -1629,14 +1640,14 @@ def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear',
1629
1640
thumbfile : str or file-like
1630
1641
The thumbnail filename.
1631
1642
1632
- scale : float, optional
1643
+ scale : float, default: 0.1
1633
1644
The scale factor for the thumbnail.
1634
1645
1635
- interpolation : str, optional
1646
+ interpolation : str, default: 'bilinear'
1636
1647
The interpolation scheme used in the resampling. See the
1637
1648
*interpolation* parameter of `~.Axes.imshow` for possible values.
1638
1649
1639
- preview : bool, optional
1650
+ preview : bool, default: False
1640
1651
If True, the default backend (presumably a user interface
1641
1652
backend) will be used which will cause a figure to be raised if
1642
1653
`~matplotlib.pyplot.show` is called. If it is False, the figure is
0 commit comments