简体   繁体   English

octave(matlab),如何创建情节而不显示?

[英]octave(matlab), how create plots without displaying?

The problem with octave(matlab). 八度音程(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. 绘制我使用scatter功能。

This is not tested with matlab, and potentially only limited to octave. 这不是用matlab测试的,可能只限于八度音阶。

Using f = figure('visible','off') will not work out of the box. 使用f = figure('visible','off')将无法开箱即用。

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. 默认值为fltk ,如果不显示绘图,则无法写入文件。 However, if you select gnuplot it will be able to write to file without displaying it first: 但是,如果您选择gnuplot ,它将能够写入文件而不首先显示它:

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. 它不是特别快,但它不使用屏幕缓冲区或捕获鼠标,如果需要显示绘图,则会发生这种情况。

正如在这个问题中回答的那样,我会这样做:

f = figure('visible','off')

Offscreen rendering is supported on GNU/Linux since GNU Octave 4.0 using OSMesa. 自GNU Octave 4.0使用OSMesa以来,GNU / Linux支持屏幕外渲染。 So today there are basically two ways to get figure ("visible", "off");... print (...) working: 所以今天基本上有两种获取figure ("visible", "off");... print (...)工作:

  1. 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. 如果您没有专有的OpenGL驱动程序,而是基于MESA的驱动程序,如radeon,nouveau等(基本上所有免费(如在自由中)驱动程序都基于Mesa)您可以使用基于OpenGL的工具包(qt,fltk),Octave将使用OSMesa用于打印。
  2. Using gnuplot: graphics_toolkit gnuplot as said before 使用gnuplot: graphics_toolkit gnuplot如前所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM