Skip to content

Variable: imshow ​

ts
const imshow: ImshowFunction;

An image or a matrix (px.imshow). A 2D array becomes a heatmap on layout.coloraxis (colorscale from the template, zmin / zmax from the data); an RGB / RGBA array ([row][col][channel]) or ImageData becomes an image trace, drawn from a PNG data URI by default. Rows run down from the top (origin: 'upper') and pixels are square (aspect: 'equal'). A third or fourth dimension can be spread over facets (facetCol) or animation frames (animationFrame).

Example ​

ts
const figure = imshow(
  [
    [1, 20, 30],
    [20, 1, 60],
  ],
  { textAuto: true, labels: { x: 'column', y: 'row', color: 'value' } },
);
await imshow(el, pixels, { facetCol: 0 }); // or render directly

Throws ​

For ragged or empty arrays, shapes other than 2D / RGB / RGBA per slice, and x / y of the wrong length (or not numeric, for images).

Released under the MIT License.