Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

Scatter plot with density in Matlab

Date: 2022-07-18 11:05:09

I would like to plot data set 1 and data set 2 in one plot vertical. Unfortunately the data is huge, so it is just a smear of points and can't see the density. I tried hist3 and other suggestions but it overwrites my data sets and the binning looks awful.

Is there another way to plot scatter density plots? Is there really no Matlab function for it? If not, which program could I use to easy generate such a plot?

A mix between this two examples: 

Answers: 

What's wrong with computing hist3 and displaying the result with imagesc

 

data1 = randn(1,1e5); %// example data
data2 = randn(1,1e5) + .5*data1 ; %// example data correlated to above
values = hist3([data1(:) data2(:)],[51 51]);
imagesc(values.')
colorbar
axis equal
axis xy

If you want to have the axes in accordance with the true data values: use the second output of hist3 to obtain the positions of the bin centers, and pass them to imagesc

 

data1 = randn(1,1e5); %// example data
data2 = 2*randn(1,1e5) + 1.2*data1 + 4; %// example data correlated to above
[values, centers] = hist3([data1(:) data2(:)],[51 51]);
imagesc(centers{:}, values.')
colorbar
axis xy

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com