用许多线改善八度音阶的性能

时间:2014-09-14 19:40:45

标签: performance optimization graph plot octave

我想知道是否有更快的方法来创建多行的3D图。请参阅下面的函数,该函数使用一些虚拟数据模拟我当前的方法。基本上,我正在做的是在3D空间中绘制彼此相邻的多条2D线以快速比较它们。每条线都按其最终y值着色。

function test_plotmany(lines = 1000, points = 100)
    # this data comes from a numeric simulation, here I just fill
    # it with some dummy values - ignore this
    t = [1:points];
    data = [];
    for i = t;
        data(end + 1, :) = [1:lines] .* i;
    endfor

    # now the actually interesting part that I want to speed up, if possible
    tic;
    tsize = size(t, 2);
    const = ones(tsize, 1);

    lines = [1:size(data, 2)];
    colors = jet(size(lines, 2));
    colormap(colors);
    cIdx = 1;

    figure
    hold on;
    for i = lines;
        plot3(t, data(1, i) .* const, data(:, i), 'Color', colors(cIdx, :));
        cIdx = cIdx + 1;
    endfor
    xlabel("Foo");
    ylabel("Bar");
    zlabel("Baz");
    grid("on");
    view(45, 45);
    set(gca, 'XScale', 'linear', 'YScale', 'log', 'ZScale', 'log');
    cb = colorbar;
    caxis([min(data(tsize, :)), max(data(tsize, :))]);
    set(get(cb, 'ylabel'), 'string', 'Something');
    hold off;
    toc;
endfunction

test_plotmany(100, 100)的结果如下所示,已经花了2秒。我必须使用test_plotmany(10000, 100)来模拟我必须处理的真实数据集的大小,这需要在我的机器上创建几分钟。

我能做些什么来加快速度吗?有没有办法创建一个3D矩阵等,并将其交给3D绘图功能来重新创建我的图形?或者我可以使用多个线程来渲染图形吗?

任何帮助将不胜感激,谢谢!

注意:我在Linux 3.16.1-1-ARCH上使用GNU Octave版本3.8.1,使用Intel(R)Core(TM)i3-2310M CPU @ 2.10GHz。在Octave中,我使用fltk graphics_toolkit - gnuplot对我来说根本不起作用(颜色错误,无法与图形交互以旋转,缩放或平移)。

0 个答案:

没有答案