savefig#

savefig(figure, filename)#

Save figure as a MATLAB .fig file.

The file stores the figure, each axes, and the lines, images, and text on those axes (data, limits, colors, scales, and labels). Title and axis labels are text children indexed by the axes special vector, which is how openfig attaches them. Figure text such as a suptitle is stored on the first axes, because openfig drops text parented to the figure. Scatter, bars, patches, and legends are omitted. A figure has one colormap, taken from the first image. Interpreter is none so label text is stored literally. Characters outside ASCII are replaced (a Unicode minus becomes -) so each MAT character array is one byte per character. Mathtext tick labels are stored as the plain tick value. Importing this module also registers Matplotlib’s fig format, so figure.savefig("name.fig") uses the same writer.

Parameters:
  • figure (Figure) – Matplotlib figure to export.

  • filename (str | PathLike[str] | BinaryIO) – Destination path. A .fig suffix is added when missing. A binary file object is written as-is.

Returns:

The path written, or the file object’s name when filename is a file object.

Return type:

str