使用散点图可视化大型 3D 数据集 [英] Visualizing large 3D dataset with scatter plot

查看:40
本文介绍了使用散点图可视化大型 3D 数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 MATLAB 中运行模拟,其中我有一个大型 3D 数据集,每个时间步长都会发生变化.我正在尝试使用 3D 散点图将数据可视化,其中点在模拟进行时呈现不同的位置、大小、颜色和透明度.尺寸和颜色信息是多余的.

I'm running a simulation in MATLAB in which I have a large 3D dataset that changes each time step. I'm trying to visualize the data using a 3D scatter plot with points that take on different locations, sizes, colors, and transparency levels as the simulation proceeds. The size and color information are redundant.

在 MATLAB 中渲染和旋转图形缓慢且断断续续.我的电脑有一个 4 GHz i7-4790 CPU 和一个 NVIDIA GeForce GTX 750 Ti 显卡.我在 Windows 7 上使用 Matlab R2016a.我检查了我的 MATLAB OpenGL 设置并且硬件支持级别已满.(硬件 OpenGL 是透明度所必需的.)此外,我正在使用 GPU-Z,并且在绘图和旋转期间,GPU 负载峰值仅为 25-30%.

Rendering and rotating the figure in MATLAB is slow and choppy. My computer has a 4 GHz i7-4790 CPU and a NVIDIA GeForce GTX 750 Ti graphics card. I am using Matlab R2016a on Windows 7. I checked my MATLAB OpenGL settings and the hardware support level is full. (Hardware OpenGL is necessary for transparency.) Moreover, I'm monitoring my GPU usage using GPU-Z, and during plotting and rotation, the GPU load peaks at only 25-30%.

这是我的代码示例:

load sample_data2
channels_matrix = cat(1, channels{:});
num_channels = length(channels);
channel_lengths = cellfun(@(x) size(x, 1), channels);

figure(1);
for i = 1:num_channels
    g = plot3(channels{i}(:, 1), channels{i}(:, 2), channels{i}(:, 3), 'k');
    set(g, 'LineWidth', 1.5)
    hold on;
    text(channels{i}(1, 1), channels{i}(1, 2), channels{i}(1, 3), num2str(i))
end
caxis([0 1])
colorbar
drawnow

numDivisions = 8;
ptsPerDivision = numel(grid_x)/numDivisions;
T = 1000;
numplotpts = 2E4;
for t = 1:T
    plot_signal = nan(size(grid_x));
    plot_signal(sort(randsample(numel(grid_x), numplotpts))) =...
        sort(rand(numplotpts, 1));
    tic
    for i = 1:numDivisions
        temp = plot_signal(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
        yplot = grid_y(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
        xplot = grid_x(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
        zplot = grid_z(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
        if t == 1
            h(i) = scatter3(yplot(~isnan(temp)), xplot(~isnan(temp)),...
                zplot(~isnan(temp)), 50*temp(~isnan(temp)), temp(~isnan(temp)), ...
                'filled', 'MarkerFaceAlpha', exp(-i)^0.25);
        else
            h(i).XData = yplot(~isnan(temp));
            h(i).YData = xplot(~isnan(temp));
            h(i).ZData = zplot(~isnan(temp));
            h(i).SizeData = 50*temp(~isnan(temp));
            h(i).CData = temp(~isnan(temp));
        end
    end
    drawnow
    toc
end

这里是数据的链接.有什么方法可以加快渲染速度并使旋转更平滑?我注意到将所有数据点的大小固定为单个标量可以大大加快渲染和旋转的速度.是否可以保持代码中的大小,并且仍然可以快速渲染和旋转图形?

and here is a link to the data. Is there any way to speed up the rendering and make rotation smoother? I noticed that fixing the size of all data points to a single scalar greatly speeds up rendering and rotation. Is it possible to keep the size as it is in the code and still have the figure render and rotate quickly?

编辑:相关问题我发布了.

推荐答案

听起来 timer 功能是下一步尝试的好地方,以便了解您的模拟进程,然后一旦您对事物的外观感到满意,就可以制作 AVI.

It sounds like the timer function is a good place to try next in order to get a sense of your simulation's progression and then making an AVI once you are satisfied with how things look.

MATLAB 为它提供了一些很棒的文档连续调用的各种选项以及它们之间的间距.查看 ExecutionModePeriod 属性.

MATLAB's got some great documentation for it with a variety of options for consecutive calls are made and the spacing between them. Check out the ExecutionMode and Period properties.

这篇关于使用散点图可视化大型 3D 数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆