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

Skip to content

Commit ab8e5cf

Browse files
committed
added resize parameter to plot 2d-arrays using figimage
1 parent f532615 commit ab8e5cf

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/matplotlib/figure.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ def hold(self, b=None):
568568
self._hold = b
569569

570570
def figimage(self, X,
571+
resize=False,
571572
xo=0,
572573
yo=0,
573574
alpha=None,
@@ -603,6 +604,8 @@ def figimage(self, X,
603604
========= =========================================================
604605
Keyword Description
605606
========= =========================================================
607+
resize a boolean, True or False. If "True", then re-size the
608+
Figure to match the given image size.
606609
xo or yo An integer, the *x* and *y* image offset in pixels
607610
cmap a :class:`matplotlib.colors.Colormap` instance, e.g.,
608611
cm.jet. If *None*, default to the rc ``image.cmap``
@@ -637,6 +640,11 @@ def figimage(self, X,
637640
if not self._hold:
638641
self.clf()
639642

643+
if resize:
644+
dpi = self.get_dpi()
645+
figsize = [x / float(dpi) for x in (X.shape[1], X.shape[0])]
646+
self.set_size_inches(figsize, forward=True)
647+
640648
im = FigureImage(self, cmap, norm, xo, yo, origin, **kwargs)
641649
im.set_array(X)
642650
im.set_alpha(alpha)

0 commit comments

Comments
 (0)