5

I am working on tone mapping operators in HDR. My question is very simple. I want to scatter plot large arrays on Matlab 2015Ra with computer specs core i5 20GB RAM. Only the scatter plot eats up the whole memory (around 92% of 20GB). I need some suggestion to plot tall arrays. I know Matlab 2018 has binscatter function but I have lower version. Thank you. Sample Code:

a=randn(21026304,1);
scatter(a,a); 

Only this code eats up the all memory.

Kanjoo
  • 111
  • 1
  • 8
  • https://stackoverflow.com/questions/13302623/matlab-scatter-plots-with-high-number-of-datapoints check if this works for you – Ander Biguri Apr 08 '18 at 09:39
  • 1
    @AnderBiguri Thanks for the suggestion. Basically, each point is getting plot in a loop in that solution. and In my case it has taken more than 15 minutes 65%memory and still running. – Kanjoo Apr 08 '18 at 09:58
  • 2
    Try this too: https://uk.mathworks.com/matlabcentral/fileexchange/45407-scatter-lds – Ander Biguri Apr 08 '18 at 10:30

1 Answers1

0

You can create a binscatter like function yourself with histcounts2! Histcounts bins the data into an NxN array which you can then visualize with imshow... this is pretty memory-efficient as every bin only takes up a couple of bytes, regardless of the input size.

% 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');

Example of custom binned scatter-plot

Tom
  • 3,281
  • 26
  • 33