Exporting figures

Figures can be exported through the GUI or the command line.

Exporting with the GUI

Figures can exported through the GUI by selecting the File | Export to... command in the figure window. The export dialog allows the user to select an export location, a filename and a file format. When exporting to vector formats, an additional dialog is presented for selecting the figure orientation (portrait or landscape).

Exporting from the command line

Figures can be exported from the command line using the xs2* commands. Each of these commands takes the following form.

xs2*(win_num, file_name [,orientation])
xs2*(fig, file_name [,orientation])

The first argument identifies the figure to export by its id (win_num) or handle (fig). The second argument indicates the name of the file. If an extension is omitted, an appropriate extension is automatically appended. The third, optional argument allows an orientation to be specified for vector formats.


The following example creates a 2d plot and exports it in various formats.

f = scf(0); // Create a new figure or select an existing figure with an id of 0.
plot2d(); // Draw a 2d plot.

// Export using the figure id.
xs2ps(0, 'plot.ps'); // Export to a PostScript file with the default portrait orientation.
xs2bmp(0, 'plot.bmp'); // Export to a bitmap file.

// Export using the figure handle.
xs2jpg(gcf(), 'plot.jpg'); // Export to a JPG file.
xs2svg(f, 'plot', 'landscape'); // Export to an SVG file with a landscape orientation. An '.svg' extension will be automatically appended to the file name.

Known issues

Scilab may fail to properly export complex figures to vector formats. Large matrices plotted using grayplot, for example, may require downsampling prior to exporting. Note that failed export operations may still produce output files.

public: howto/exporting graphics (last edited 2011-03-31 15:39:39 by simon.gareste@scilab.org)