散点图:高大的阵列占用了所有的记忆

Kan*_*joo 5 arrays matlab scatter-plot matlab-figure

我正在研究HDR中的色调映射运算符.我的问题很简单.我想在Matlab 2015Ra上使用计算机规格核心i5 20GB RAM分散绘图大型数组.只有散点图会占用整个内存(大约占20GB的92%).我需要一些建议来绘制高阵列.我知道Matlab 2018有binscatter功能,但我的版本较低.谢谢.示例代码:

a=randn(21026304,1);
scatter(a,a); 
Run Code Online (Sandbox Code Playgroud)

只有这段代码会占用所有内存.

Tom*_*Tom 0

您可以binscatter自己创建一个类似的函数histcounts2!Histcounts 将数据分箱到 NxN 数组中,然后您可以使用该数组进行可视化imshow...这非常节省内存,因为无论输入大小如何,每个箱只占用几个字节。

% Some (correlated) data
x = randn(1e6,1);
y = randn(1e6,1)+x;

% Count 32x32 bins
[N,ax,ay] = histcounts2(x,y,32);

% Some gradient
cmap = [linspace(1,0,16);
    linspace(1,0.3,16);
    linspace(1,0.5,16)].';

% Show the histogram
imshow(...
    N,[],...                        % N contains the counts, [] indicated range min-max
    'XData', ax, 'YData', ay, ...   % Axis ticks
    'InitialMagnification', 800,... % Enlarge 8x
    'ColorMap', cmap...             % The colormap
);

colorbar;       
axis on;
title('bin-counts');
Run Code Online (Sandbox Code Playgroud)

自定义分箱散点图示例