hgsave — Save figures, or parent figures of graphics handles, as RunMat FIG files.

hgsave saves the current figure, a figure handle, or the parent figures of graphics handles to RunMat FIG files. RunMat FIG persistence is figure-scene based; arbitrary graphics-subtree FIG files are not emitted yet.

Syntax

ok = hgsave(filename)
ok = hgsave(h, filename)
ok = hgsave(..., version)

Inputs

NameTypeRequiredDefaultDescription
argsAnyVariadicMATLAB-compatible figure persistence arguments.

Returns

NameTypeDescription
okLogicalArrayTrue when the save operation completed.

Errors

IdentifierWhenMessage
RunMat:figurePersistence:InvalidArgumentArguments are missing, malformed, or incompatible with the requested figure persistence operation.figure persistence: invalid argument
RunMat:figurePersistence:UnsupportedFormatThe requested save/load format is recognized but not supported by RunMat's active plotting exporter.figure persistence: unsupported format
RunMat:figurePersistence:IoFailureThe target file cannot be read, written, flushed, synced, or atomically replaced.figure persistence: file I/O failed

How hgsave works

  • hgsave(filename) saves the current figure and appends .fig when needed.
  • hgsave(h, filename) accepts scalar handles and handle arrays, deduplicating handles that resolve to the same parent figure.
  • Version options -v6, -v7, and -v7.3 are accepted for MATLAB compatibility and map to RunMat's FIG scene format.

Does RunMat run hgsave on the GPU?

No numeric GPU kernel is launched.

Saved figures use the same scene exporter as savefig.

GPU memory and residency

hgsave is an I/O sink and returns a host logical status.

Example

Save a graphics hierarchy

plot(1:4);
hgsave(gcf, "legacy_plot.fig");

Using hgsave with coding agents

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

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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how hgsave 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.