Make distribution visible in scatter plots
2 次查看(过去 30 天)
显示 更早的评论
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]);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!