plotlet v0.6.6

image_rgba

Gridded & matrix

Minimal call

earth = pt.load_dataset("earth")   # (256, 256, 3) uint8 — Apollo 17, NASA

c = pt.chart(data_width=256, data_height=256)
c.add_image_rgba(earth)

Worked example

import plotlet as pt

earth = pt.load_dataset("earth")   # (256, 256, 3) uint8 — Apollo 17, NASA
zoom = earth[16:112, 72:168]       # a slice IS a crop

full = pt.chart(title="the blue marble", data_width=224, data_height=224)
full.add_image_rgba(earth)

crop = pt.chart(title="earth[16:112, 72:168]", data_width=224, data_height=224)
crop.add_image_rgba(zoom)

c = full | crop

Docstring

(H, W, 3|4) pixel array → image. Each cell already IS a color.

The counterpart of `add_image_cmap`: no colormap, no vmin/vmax/norm, no
colorbar — the array carries final RGB(A) values. For a 2-D matrix of
scalars that needs a colormap, use `add_image_cmap` instead.

Input is a decoded pixel array, not a file path — decode with PIL /
imageio yourself (`np.asarray(Image.open(p))`). Channel convention
follows matplotlib: float values are 0..1, integer values 0..255; both
are clipped and stored as 8-bit channels. A fully-opaque RGBA array
canonicalizes to RGB at record time (same pixels, smaller PNG).

`origin` defaults to `"upper"` — row 0 at the TOP, so a photo displays
as-seen — and the panel auto-inverts the y-axis to match (this is the
opposite default from `add_image_cmap`, whose matrices are Cartesian by
default). Pass `origin="lower"` for row 0 at the bottom.

Rendering branches like image_cmap: one <rect> per pixel below
`image_max_rects` (sharp at any zoom), one base64 PNG above. An image
denser than `raster.oversample` pixels per display pixel is mean-pooled
per channel to that cap first — integer arithmetic end-to-end, so the
byte-identical-SVG guarantee holds.