Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

octave(matlab), how create plots without displaying?

Tags:

matlab

octave

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.

like image 543
ashim Avatar asked Jan 04 '12 04:01

ashim


People also ask

How do you overlay plots in octave?

Overlaying plots To overlay multiple plots on the same frame, use hold on command. You can also plot multiple plots in the same command as plot(x,y, x,z) which will overlay both y and z on the same plot window. To close the current figure, call the close command.


2 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.

like image 163
Anne van Rossum Avatar answered Nov 15 '22 12:11

Anne van Rossum


As answered in this question, I would do:

f = figure('visible','off')
like image 42
Oli Avatar answered Nov 15 '22 11:11

Oli