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
hgsave(filename)
hgsave(h, filename)
hgsave(..., version)
ok = hgsave(___)Inputs
args- Type
Any- Required
- Variadic
- Description
- Graphics hierarchy, filename, and optional version.
Returns
ok- Type
LogicalArray- Description
- RunMat-only logical completion status when one output is requested.
Errors
RunMat:figurePersistence:InvalidArgument- When
- Arguments are missing, malformed, or incompatible with the requested figure persistence operation.
- Message
figure persistence: invalid argument
RunMat:figurePersistence:UnsupportedFormat- When
- The requested save/load format is recognized but not supported by RunMat's active plotting exporter.
- Message
figure persistence: unsupported format
RunMat:figurePersistence:IoFailure- When
- The target file cannot be read, written, flushed, synced, or atomically replaced.
- Message
figure persistence: file I/O failed
Forms
hgsave(filename) saves the current figure. hgsave(h,filename) accepts scalar double graphics handles and handle arrays. An array cannot contain an object together with one of its ancestors or descendants. The typed roots retain input order during admission. The current archive still collapses each accepted root to its parent figure and stores the first occurrence of each parent, so arbitrary top-level graphics-subtree persistence remains incomplete.
-v6, -v7, -v7.3, and compact select bounded encoding profiles inside RunMat's versioned scene archive. They do not establish MATLAB FIG binary interchange.
Execution and residency
The operation is an I/O sink and fusion boundary. Typed-integer handle spellings and gpuArray numeric arguments reject before file effects. No numeric GPU kernel is launched; scene data uses the same exporter as savefig.
In RunMat compatibility mode, requesting one output returns a host logical completion status. MATLAB compatibility mode rejects that extension before file effects.
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.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
Source you can read
Every RunMat function's source is public. Read exactly how hgsave is executed, line by line, in Rust.
- View the source for hgsave in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.