RunMat
GitHub

imagesc — Display scaled matrix images for heatmaps, colormaps, and MATLAB imagesc style visualization.

imagesc is the scaled-image member of the modern image family. In RunMat it is ideal for matrix heatmaps and value-driven raster visualization because the matrix is interpreted through colormap and color-limit semantics rather than through direct truecolor object semantics. The returned handle is still an image-handle object, but the visual meaning differs from image because imagesc is specifically about scaled matrix visualization.

How imagesc works in RunMat

  • imagesc(C) displays a matrix using implicit axes and scaled color mapping.
  • imagesc(X, Y, C) places the scaled image explicitly on the axes using the provided coordinate extents.
  • Unlike image, imagesc is fundamentally about colormap-driven value visualization rather than direct indexed/truecolor graphics-object placement.
  • The returned value is still an image-handle object in the shared plotting handle system.
  • imagesc works naturally with colormap, colorbar, caxis, and subplot-local axes state.

Examples

Display a matrix as a heatmap-style scaled image

[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));
A = sin(X) .* cos(Y);
imagesc(A);
colorbar;

Place a scaled image on explicit axes

A = reshape(1:100, 10, 10);
imagesc([-5 5], [0 1], A);
colormap('parula');

Use subplot-local color workflows

[X, Y] = meshgrid(linspace(-3, 3, 40), linspace(-3, 3, 40));
Z = sin(X) .* cos(Y);
subplot(1, 2, 1);
imagesc(Z);
colormap('jet');
colorbar;
subplot(1, 2, 2);
imagesc(magic(20));
colormap('gray');

Dense matrix as a heatmap

[X, Y] = meshgrid(linspace(-pi, pi, 300), linspace(-pi, pi, 300));
Z = sin(3*X) .* cos(2*Y) + cos(X.*Y);

imagesc(Z);
colormap('turbo');
colorbar;
title('Scalar Field Heatmap');
xlabel('Column');
ylabel('Row');
axis equal;
Expected output:
Dense matrix as a heatmap

FAQ

What's the difference between imagesc and image?

imagesc maps a 2-D matrix through the colormap with automatic scaling — the min value maps to the bottom of the colormap and the max to the top. image treats input as direct indexed or truecolor data without automatic scaling. Use imagesc for heatmaps and value visualization; use image when you have actual image pixel data (RGB arrays or pre-indexed values).

How does colormap scaling work with imagesc?

imagesc sets the color limits (caxis) to [min(C(:)), max(C(:))] automatically. Every value in the matrix maps linearly into that range across the active colormap. To override the auto-scaling, call caxis([lo hi]) after imagesc.

imagesc(A);
caxis([-1 1]);
colorbar;

How do I display a matrix as a heatmap?

Pass the matrix directly to imagesc and add a colorbar for the legend. Pair with a colormap that suits your data — diverging maps like 'coolwarm' work well for data centered around zero, sequential maps like 'parula' for positive-only ranges.

imagesc(myMatrix);
colormap('parula');
colorbar;

These functions work well alongside imagesc. Each page has runnable examples you can try in the browser.

image, colorbar, colormap, axis

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how imagesc works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Open the sandbox and start running MATLAB code in seconds. No account required.