1313import numpy as np
1414import PIL .PngImagePlugin
1515
16- from matplotlib import rcParams
16+ import matplotlib as mpl
1717import matplotlib .artist as martist
1818from matplotlib .backend_bases import FigureCanvasBase
1919import matplotlib .colors as mcolors
5858def composite_images (images , renderer , magnification = 1.0 ):
5959 """
6060 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.
6262
6363 Parameters
6464 ----------
@@ -75,13 +75,11 @@ def composite_images(images, renderer, magnification=1.0):
7575
7676 Returns
7777 -------
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.
8583 """
8684 if len (images ) == 0 :
8785 return np .empty ((0 , 0 , 4 ), dtype = np .uint8 ), 0 , 0
@@ -119,7 +117,7 @@ def _draw_list_compositing_images(
119117 Draw a sorted list of artists, compositing images into a single
120118 image where possible.
121119
122- For internal matplotlib use only: It is here to reduce duplication
120+ For internal Matplotlib use only: It is here to reduce duplication
123121 between `Figure.draw` and `Axes.draw`, but otherwise should not be
124122 generally useful.
125123 """
@@ -245,7 +243,7 @@ def __init__(self, ax,
245243 cm .ScalarMappable .__init__ (self , norm , cmap )
246244 self ._mouseover = True
247245 if origin is None :
248- origin = rcParams ['image.origin' ]
246+ origin = mpl . rcParams ['image.origin' ]
249247 cbook ._check_in_list (["upper" , "lower" ], origin = origin )
250248 self .origin = origin
251249 self .set_filternorm (filternorm )
@@ -745,12 +743,12 @@ def set_interpolation(self, s):
745743
746744 Parameters
747745 ----------
748- s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16',
746+ s : {'antialiased', 'nearest', 'bilinear', 'bicubic', 'spline16', \
749747 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', \
750748 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'none'} or None
751749 """
752750 if s is None :
753- s = rcParams ['image.interpolation' ]
751+ s = mpl . rcParams ['image.interpolation' ]
754752 s = s .lower ()
755753 cbook ._check_in_list (_interpd_ , interpolation = s )
756754 self ._interpolation = s
@@ -774,7 +772,7 @@ def set_resample(self, v):
774772 If None, use :rc:`image.resample`.
775773 """
776774 if v is None :
777- v = rcParams ['image.resample' ]
775+ v = mpl . rcParams ['image.resample' ]
778776 self ._resample = v
779777 self .stale = True
780778
@@ -1512,7 +1510,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15121510 fname = os .fspath (fname )
15131511 if format is None :
15141512 format = (Path (fname ).suffix [1 :] if isinstance (fname , str )
1515- else rcParams ["savefig.format" ]).lower ()
1513+ else mpl . rcParams ["savefig.format" ]).lower ()
15161514 if format in ["pdf" , "ps" , "eps" , "svg" ]:
15171515 # Vector formats that are not handled by PIL.
15181516 if pil_kwargs is not None :
@@ -1529,7 +1527,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15291527 sm = cm .ScalarMappable (cmap = cmap )
15301528 sm .set_clim (vmin , vmax )
15311529 if origin is None :
1532- origin = rcParams ["image.origin" ]
1530+ origin = mpl . rcParams ["image.origin" ]
15331531 if origin == "lower" :
15341532 arr = arr [::- 1 ]
15351533 rgba = sm .to_rgba (arr , bytes = True )
@@ -1548,7 +1546,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
15481546 format = "jpeg" # Pillow doesn't recognize "jpg".
15491547 color = tuple (
15501548 int (x * 255 )
1551- for x in mcolors .to_rgb (rcParams ["savefig.facecolor" ]))
1549+ for x in mcolors .to_rgb (mpl . rcParams ["savefig.facecolor" ]))
15521550 background = PIL .Image .new ("RGB" , pil_shape , color )
15531551 background .paste (image , image )
15541552 image = background
0 commit comments