The 'scatplot' command takes in column matrix x & y and performs a density based scatter plot as shown in this example:
>> x = randn(1,1000);
>> y = randn(1,1000);
>> scatplot(x,y);
>> colorbar;
The link to the 'scatplot' can be found here :
https://www.mathworks.com/matlabcentral/fileexchange/8577-scatplot
Another File Exchange function called 'dscatter' performs a similar plot.
The File Exchange link can be found here:
>> x = randn(1000,1);
>> y = randn(1000,1);
>> dscatter(x,y)
We can visualize the density within a grid in MATLAB by binning using the hist3 function and subsequently plotting it as follows:
>> x = randn(1,1000);
>> y = randn(1,1000);
>> n = hist3([x', y']);
>> pcolor(n);
To query the coordinates for a color range, please refer the following:
The function 'getDataForColorRange' in the attachment accepts an Axes handle returned by the 'dscatter' function and a color range.
For example, let us plot the following:
>> x = randn(1000,1);
>> y = randn(1000,1);
>> f = dscatter(x,y);
>> colorbar;
We can query all the X and Y coordinates that are present in the color range 0.7 to 0.9 as follows:
>> [x,y,idx] = getDataForColorRange(f,[0.7 0.9]);
To view this data, we can update the scatter plot as follows:
>> c = f.Children;
>> c.CData(~idx) = NaN;
Best Answer