MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / FigureImage

Class FigureImage

lib/matplotlib/image.py:1344–1407  ·  view source on GitHub ↗

An image attached to a figure.

Source from the content-addressed store, hash-verified

1342
1343
1344class FigureImage(_ImageBase):
1345 """An image attached to a figure."""
1346
1347 zorder = 0
1348
1349 _interpolation = 'nearest'
1350
1351 def __init__(self, fig,
1352 *,
1353 cmap=None,
1354 norm=None,
1355 colorizer=None,
1356 offsetx=0,
1357 offsety=0,
1358 origin=None,
1359 **kwargs
1360 ):
1361 """
1362 cmap is a colors.Colormap instance
1363 norm is a colors.Normalize instance to map luminance to 0-1
1364
1365 kwargs are an optional list of Artist keyword args
1366 """
1367 super().__init__(
1368 None,
1369 norm=norm,
1370 cmap=cmap,
1371 colorizer=colorizer,
1372 origin=origin
1373 )
1374 self.set_figure(fig)
1375 self.ox = offsetx
1376 self.oy = offsety
1377 self._internal_update(kwargs)
1378 self.magnification = 1.0
1379
1380 def get_extent(self):
1381 """Return the image extent as tuple (left, right, bottom, top)."""
1382 numrows, numcols = self.get_size()
1383 return (-0.5 + self.ox, numcols-0.5 + self.ox,
1384 -0.5 + self.oy, numrows-0.5 + self.oy)
1385
1386 def make_image(self, renderer, magnification=1.0, unsampled=False):
1387 # docstring inherited
1388 fig = self.get_figure(root=True)
1389 fac = renderer.dpi/fig.dpi
1390 # fac here is to account for pdf, eps, svg backends where
1391 # figure.dpi is set to 72. This means we need to scale the
1392 # image (using magnification) and offset it appropriately.
1393 bbox = Bbox([[self.ox/fac, self.oy/fac],
1394 [(self.ox/fac + self._A.shape[1]),
1395 (self.oy/fac + self._A.shape[0])]])
1396 width, height = fig.get_size_inches()
1397 width *= renderer.dpi
1398 height *= renderer.dpi
1399 clip = Bbox([[0, 0], [width, height]])
1400 return self._make_image(
1401 self._A, bbox, bbox, clip, magnification=magnification / fac,

Callers 1

test_figureimage_setdataFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_figureimage_setdataFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…