- 1 year ago
Octave: hide window of a complex plot; print to file instead
In Octave, if you want to hide the window of a complex plot and save it directly to a file instead, you can use the print
function along with the -dpng
or -dsvg
options to save the plot as a PNG or SVG file, respectively. Here's an example:
octavex = linspace(0, 2*pi, 100);
y = exp(1i * x);
% Plot the complex values
plot(x, y);
% Hide the plot window
set(gcf, 'Visible', 'off');
% Save the plot to a PNG file
print('complex_plot.png', '-dpng');
% Save the plot to an SVG file
print('complex_plot.svg', '-dsvg');
In this example, the plot
function is used to generate a complex plot. The set
function is then used to set the visibility of the figure window to 'off'
, effectively hiding it.
The print
function is then called to save the plot as both a PNG file (complex_plot.png
) and an SVG file (complex_plot.svg
) using the -dpng
and -dsvg
options, respectively.
By running this code in Octave, the plot window will be hidden, and the plot will be saved directly to the specified files without being displayed on the screen.
Feel free to modify the code as per your specific needs, such as adjusting the plot data or customizing the output file names and formats.