Make distribution visible in scatter plots

조회 수: 1 (최근 30일)
Joel Schelander
Joel Schelander 2021년 5월 17일
편집: Adam Danz 2021년 5월 17일
I have two vectors, I3 and D, of the size 1000000x1. They are plotted against each other in a scatter plot (see PIplot1)
I want to know how many values I have. For example If you look to the far right of the figure. I dont know How many values are around y=50 or how many are around y=150.
I need to make the distribution visible somehow, but I do not know how to go about it.
plot(I3,D,'.','Color', [0 0.4470 0.7410]);

채택된 답변

Adam Danz
Adam Danz 2021년 5월 17일
편집: Adam Danz 2021년 5월 17일
You can display the 2D binned density using histogram2.
Demo: The plot on the left and right contain the same data.
x = 1:105;
ym = randn(800, numel(x)) .* linspace(2,35,numel(x)) + linspace(6,150,numel(x)) ;
xm = repmat(x,size(ym,1),1);
figure()
tiledlayout(1,2)
ax(1) = nexttile;
plot(x,ym,'b.')
grid on
axis tight
ax(2) = nexttile;
histogram2(xm,ym,'DisplayStyle','tile')
axis tight
cb = colorbar();
ylabel(cb, 'bin count')
linkaxes(ax)
Also try setting BinMethod or or bin edges in histogram2.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by