RunMat
GitHub

print — Export figures to files in MATLAB and RunMat.

print exports the active or specified figure to files. Device tokens, resolution options, and argument forms follow MATLAB-style print semantics in RunMat.

Syntax

ok = print(filename, '-dpng')
ok = print(filename, '-dpng', '-r300')
ok = print(fig, filename, '-dpng')
ok = print('-dpng', filename)

Inputs

NameTypeRequiredDefaultDescription
argsAnyVariadicOptional figure handle, filename, device token such as '-dpng', and resolution token such as '-r300'.

Returns

NameTypeDescription
okLogicalArrayTrue when the export completed.

Errors

IdentifierWhenMessage
RunMat:print:InvalidInputArguments are missing, malformed, or cannot be interpreted as a supported print form.print: invalid input arguments
RunMat:print:UnsupportedDeviceThe requested output device is not supported by the active exporter.print: unsupported output device
RunMat:print:InvalidOptionA print option token is unsupported or invalid.print: invalid option

How print works

  • print(filename, '-dpng') writes PNG bytes to filename. If the name has no .png extension, RunMat appends one.
  • print(filename, '-dpng', '-rN') scales the export dimensions from the default 800 by 600 canvas using N DPI relative to RunMat's 150 DPI default.
  • print(fig, filename, '-dpng') exports the specified figure handle instead of the active figure.
  • Command-style argument order is accepted when RunMat parses command calls into string arguments, such as print -dpng plot.png.
  • PDF, EPS, and SVG device tokens are recognized but return a clear unsupported-device error until those exporters are implemented.

Does RunMat run print on the GPU?

No numeric GPU kernels are launched for print itself.

The PNG exporter first attempts the interactive GPU render path and falls back to CPU rasterization when headless GPU initialization is unavailable.

The builtin writes PNG bytes through RunMat's filesystem layer, so output storage is host or virtual-filesystem backed.

GPU memory and residency

print is an I/O sink and returns a host logical status. Filename and option arguments are gathered before parsing. GPU-resident plot data already captured in figure state may still be consumed by the plotting renderer without forcing user-visible gathers when the shared WGPU export path is available.

Examples

Export the active figure to a PNG file

x = 0:0.1:2*pi;
plot(x, sin(x));
print("sine_plot", "-dpng");

Export at a higher resolution

x = 0:0.1:1;
plot(x, x.^2, "LineWidth", 2);
print("quadratic_plot", "-dpng", "-r300");

Export a specific figure handle

fig = figure();
plot(1:5, [1 4 2 5 3]);
print(fig, "explicit_handle_plot.png", "-dpng");

Command-style device order

plot(1:4, [1 3 2 4]);
print -dpng command_style_plot.png

Using print with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how print changes the result.

Run a small print example, explain the result, then change one input and compare the output.

FAQ

Which formats does print support?

PNG is supported today with -dpng. RunMat recognizes PDF, EPS, and SVG device tokens, but they return an unsupported-device error until those exporters are available in the rendering stack.

Where does the file go in the browser?

The PNG is written through RunMat's filesystem provider. In the sandbox this is usually the in-memory or IndexedDB-backed virtual filesystem, and the host can expose the file as a download artifact.

Does -r300 change the figure data?

No. It only changes the pixel dimensions used for export. The plot data and graphics handles remain unchanged.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · suptitle · xline · yline

More plotting resources

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.