I have a Matlab application that I wrote and would like to put on a AWS server running Octave to make a service publicly available via the web. I\'ve never used Octave.
In theory it should work as expected.
Things to keep in mind and try to work around include the following:
If your environment does not provide an X DISPLAY, only the gnuplot graphics toolkit will be available. If you'd like to 'fake' an x display to allow you use of other graphics toolkits (e.g. graphics_toolkit('qt')
), consider running octave via xvfb-run, which simulates a 'dumb' x server. (i.e. launch octave as xvfb-run octave
, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805295 ).
Occasionally OpenGl complains when you try to plot things that are 'offscreen'. This problem can be worked around if your images are set to non-visible as default, which still allows them to be printed without necessarily appearing on screen. To do this, set the 'root' figure object to non-visible before plotting anything:
set(0, 'defaultfigurevisible', 'off')
Concretely, your code might look like this:
gnuplot_toolkit('qt';) # optional, if run via xvfb-run or the AWS supports an X Display
set(0, 'defaultfigurevisible', 'off');
h = plot( 1 : 10 );
saveas( h, 'out.png', 'png' ); # you can replace 'png' with 'gif' or 'jpg' etc.