Alphabetical list Categories
gimage Place an image with data and paper coordinates
Call signature:

gimage(img, drect=None, prect=None, aspect=1, anchor=0)

Help text:

gimage(img, drect, prect) places an image on a location in the graph specified by both data coordinates and image coordinates.
For example: gimage(img, [5, 5, 0, 0], [0, 0, 36, 72]) creates an image of 0.5x1" at data location (5,5). gimage(img, [5, np.nan, 0, 5], [0, 36, 72, 0]) creates an image 1" wide, 5 data units high, at x=5, 1" below the top of the graph.
Etc.
gimage may also be used to create an image with explicitly square pixels. To do that, specify h_data=0 and h_paper=0 to let w_data and/or w_paper define the image size, or specify w_data=0 and w_paper=0 to let h_data and/or h_paper define the image size. Specify aspect>1 to make the pixels taller or aspect<1 to make them wider.
If height is automatic, then the image descends from the given point, unless anchor>0, in which case it is lifted by the given fraction of image height. Similarly, if width is automatic, the image extends to the right of the given point, unless anchor>0, in which case it is shifted to the left by the given fraction.

Example:

import qplot as qp

import numpy as np

qp.figure('gimage', 3, 3)

xx = np.tile(np.arange(10), (10,1))

yy = np.transpose(xx)

r = xx/10

g = yy/10

b = .5+0*xx

img = np.dstack((r,g,b))

qp.gimage(img, [np.nan, np.nan, 0, 0], np.array([.5, .5, 2, 2])*72)

QPlot Documentation — (C) Daniel Wagenaar, 2014–2023