13
13
import numpy as np
14
14
import PIL .PngImagePlugin
15
15
16
- from matplotlib import rcParams
16
+ import matplotlib as mpl
17
17
import matplotlib .artist as martist
18
18
from matplotlib .backend_bases import FigureCanvasBase
19
19
import matplotlib .colors as mcolors
58
58
def composite_images (images , renderer , magnification = 1.0 ):
59
59
"""
60
60
Composite a number of RGBA images into one. The images are
61
- composited in the order in which they appear in the ` images` list.
61
+ composited in the order in which they appear in the * images* list.
62
62
63
63
Parameters
64
64
----------
@@ -75,13 +75,11 @@ def composite_images(images, renderer, magnification=1.0):
75
75
76
76
Returns
77
77
-------
78
- tuple : image, offset_x, offset_y
79
- Returns the tuple:
80
-
81
- - image: A numpy array of the same type as the input images.
82
-
83
- - offset_x, offset_y: The offset of the image (left, bottom)
84
- in the output figure.
78
+ image : uint8 3d array
79
+ The composited RGBA image.
80
+ offset_x, offset_y : float
81
+ The (left, bottom) offset where the composited image should be placed
82
+ in the output figure.
85
83
"""
86
84
if len (images ) == 0 :
87
85
return np .empty ((0 , 0 , 4 ), dtype = np .uint8 ), 0 , 0
@@ -119,7 +117,7 @@ def _draw_list_compositing_images(
119
117
Draw a sorted list of artists, compositing images into a single
120
118
image where possible.
121
119
122
- For internal matplotlib use only: It is here to reduce duplication
120
+ For internal Matplotlib use only: It is here to reduce duplication
123
121
between `Figure.draw` and `Axes.draw`, but otherwise should not be
124
122
generally useful.
125
123
"""
@@ -245,7 +243,7 @@ def __init__(self, ax,
245
243
cm .ScalarMappable .__init__ (self , norm , cmap )
246
244
self ._mouseover = True
247
245
if origin is None :
248
- origin = rcParams ['image.origin' ]
246
+ origin = mpl . rcParams ['image.origin' ]
249
247
cbook ._check_in_list (["upper" , "lower" ], origin = origin )
250
248
self .origin = origin
251
249
self .set_filternorm (filternorm )
@@ -745,12 +743,12 @@ def set_interpolation(self, s):
745
743
746
744
Parameters
747
745
----------
748
- s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16',
746
+ s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', \
749
747
'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', \
750
748
'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
751
749
"""
752
750
if s is None :
753
- s = rcParams ['image.interpolation' ]
751
+ s = mpl . rcParams ['image.interpolation' ]
754
752
s = s .lower ()
755
753
cbook ._check_in_list (_interpd_ , interpolation = s )
756
754
self ._interpolation = s
@@ -774,7 +772,7 @@ def set_resample(self, v):
774
772
If None, use :rc:`image.resample`.
775
773
"""
776
774
if v is None :
777
- v = rcParams ['image.resample' ]
775
+ v = mpl . rcParams ['image.resample' ]
778
776
self ._resample = v
779
777
self .stale = True
780
778
@@ -1512,7 +1510,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
1512
1510
fname = os .fspath (fname )
1513
1511
if format is None :
1514
1512
format = (Path (fname ).suffix [1 :] if isinstance (fname , str )
1515
- else rcParams ["savefig.format" ]).lower ()
1513
+ else mpl . rcParams ["savefig.format" ]).lower ()
1516
1514
if format in ["pdf" , "ps" , "eps" , "svg" ]:
1517
1515
# Vector formats that are not handled by PIL.
1518
1516
if pil_kwargs is not None :
@@ -1529,7 +1527,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
1529
1527
sm = cm .ScalarMappable (cmap = cmap )
1530
1528
sm .set_clim (vmin , vmax )
1531
1529
if origin is None :
1532
- origin = rcParams ["image.origin" ]
1530
+ origin = mpl . rcParams ["image.origin" ]
1533
1531
if origin == "lower" :
1534
1532
arr = arr [::- 1 ]
1535
1533
rgba = sm .to_rgba (arr , bytes = True )
@@ -1548,7 +1546,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
1548
1546
format = "jpeg" # Pillow doesn't recognize "jpg".
1549
1547
color = tuple (
1550
1548
int (x * 255 )
1551
- for x in mcolors .to_rgb (rcParams ["savefig.facecolor" ]))
1549
+ for x in mcolors .to_rgb (mpl . rcParams ["savefig.facecolor" ]))
1552
1550
background = PIL .Image .new ("RGB" , pil_shape , color )
1553
1551
background .paste (image , image )
1554
1552
image = background
0 commit comments