getframe

Captures the current axes or figure as a movie frame.

Category: Graphics > 2-D and 3-D Plots

Syntax

F = getframe

Captures the current axes.

F = getframe(ax)

Captures the axes ax.

F = getframe(fig)

Captures the whole figure fig.

Description

getframe renders what is on screen into pixels. Collect the frames of an animation in a struct array, then play them with movie or turn one into an image with frame2im.

Input arguments

ax
Axes handle to capture.
fig
Figure handle to capture.

Output arguments

F
Structure with the fields cdata, the captured pixels as an m-by-n-by-3 uint8 array, and colormap, which is empty.

Example

Capture a plot

plot(1:5, [2 4 1 5 3])
try
    F = getframe;
    disp(fieldnames(F))
catch
end

In the app the field names cdata and colormap are listed.

Notes

It needs the renderer of the MatLivre app. In the headless command-line runner there is no renderer, so getframe fails there with an error.

See also

frame2im im2frame movie print exportgraphics