The problem with octave(matlab). In the program I have loop where I plot data. In the end of each loop I save plots to disc. During this process octave draw each plot. It slows down the process. I need only plots to be saved on disc. If I could not display them,but just save, it would considerably accelerate the process. Is there way to draw plot to handler without displaying it? to draw I use scatter function.
-
possible duplicate of In MATLAB, how do I plot to an image and save the result without displaying it?yuk– yuk2012-01-04 15:32:23 +00:00Commented Jan 4, 2012 at 15:32
-
4This is not really a duplicate, since this is about OCTAVE not MATLAB.Ramiro– Ramiro2014-06-19 15:23:16 +00:00Commented Jun 19, 2014 at 15:23
3 Answers
This is not tested with matlab, and potentially only limited to octave.
Using f = figure('visible','off') will not work out of the box.
You need to select a proper graphics toolkit:
available_graphics_toolkits
ans =
{
[1,1] = fltk
[1,2] = gnuplot
}
The default is fltk which cannot write to file without displaying the plot. However, if you select gnuplot it will be able to write to file without displaying it first:
graphics_toolkit gnuplot
f = figure('visible','off')
plot(...)
axis(...)
filename=sprintf('output/%05d.png',t);
print(filename);
It is not particularly fast, but it doesn't use screen buffers or captures the mouse, which happens if the plot needs to be visible.
2 Comments
fltk and nonvisible figure one may need to recompile octave if you receive error: __osmesa_print__: support for offscreen rendering was disabled when Octave was builtAs answered in this question, I would do:
f = figure('visible','off')
2 Comments
Offscreen rendering is supported on GNU/Linux since GNU Octave 4.0 using OSMesa. So today there are basically two ways to get figure ("visible", "off");... print (...)working:
- If you not have a proprietary OpenGL driver but a MESA based driver like radeon, nouveau and so on (basically all free (as in freedom) drivers are based on Mesa) you can use OpenGL based toolkits (qt, fltk) and Octave will use OSMesa for printing.
- Using gnuplot:
graphics_toolkit gnuplotas said before