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

Skip to content

Commit 70358ac

Browse files
committed
Allow imsave() to handle RGB(A) input arrays
Thanks to Jostein Be Floystad for the original patch!
1 parent 447a7cc commit 70358ac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
12431243
If *format* is *None* and *fname* is a string, the output
12441244
format is deduced from the extension of the filename.
12451245
*arr*:
1246-
A 2D array.
1246+
An MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA) array.
12471247
Keyword arguments:
12481248
*vmin*/*vmax*: [ None | scalar ]
12491249
*vmin* and *vmax* set the color scaling for the image by fixing the
@@ -1266,7 +1266,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
12661266
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
12671267
from matplotlib.figure import Figure
12681268

1269-
figsize = [x / float(dpi) for x in arr.shape[::-1]]
1269+
figsize = [x / float(dpi) for x in (arr.shape[1], arr.shape[0])]
12701270
fig = Figure(figsize=figsize, dpi=dpi, frameon=False)
12711271
canvas = FigureCanvas(fig)
12721272
im = fig.figimage(arr, cmap=cmap, vmin=vmin, vmax=vmax, origin=origin)

0 commit comments

Comments
 (0)