matlab:具有大量数据点的散点图 [英] matlab: scatter plots with high number of datapoints

查看:53
本文介绍了matlab:具有大量数据点的散点图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制散点图,例如:

scatter(coor(:, 2), coor(:, 3), 1, coor(:, 4));

问题是,我有相当多的坐标要绘制(~100 000).绘制它需要很长时间,当我尝试将图形导出到 tiff 时 - 然后 matlab 已经死了几分钟......有什么解决方案可以改善绘图,或者至少是 tiff 导出?

忘了说,第三个坐标 (coor(:, 4)) 是一个颜色代码.

所以,当我使用 scatter(如上)时,我在下面的图片中有类似的东西,这正是我想要看到的(只是它超级慢,我无法导出):

当我这样做时:

<块引用>

plot3(coor(:, 2), coor(:, 3), coor(:, 4), '.')

效果不再那么酷了(注意:图像不是来自同一坐标...):

解决方案

您可以使用 plot,但所有点都具有相同的颜色.但是,您可以将集合划分为不同的子集,并用自己的颜色绘制每个子集:

N = 100000;x = rand(N,1);y = rand(N,1);C = sin(2*x)+y;cdivs = 10;[~, 边缘] = hist(C,cdivs-1);边缘 = [-Inf 边缘 Inf];% 包括所有点[Nk, bink] = histc(C,edges);数字;坚持,稍等;cmap = jet(cdivs);对于 ii=1:cdivsidx = bink==ii;plot(x(idx),y(idx),'.','MarkerSize',4,'Color',cmap(ii,:));结尾颜色图(cmap)caxis([min(C) max(C)])颜色条

它的响应已经比 scatter(x,y,1,C) 好很多,后者给出了大致相同的图,但具有更高的颜色分辨率(可在我上面的代码中进行调整).

I'm trying to plot scatter, something like:

scatter(coor(:, 2), coor(:, 3), 1, coor(:, 4));

The problem is, that I have quite big number of coordinates to plot (~100 000). Its taking long time to plot it, and when I try to export figure to tiff - then matlab is dead for goooood few minutes... Any solution to improve plotting, or at least tiff export?

EDIT: Forgot to mention, 3rd coordinate (coor(:, 4)) is a color code.

So, when I'm using scatter (as above), I have something like on the image below, and thats exactly how I want to see it (just its super slow and I can't export that):

When I do:

plot3(coor(:, 2), coor(:, 3), coor(:, 4), '.')

effect is not as cool any more (note: images are not from the same coordinates...) :

解决方案

You can use plot, but then all points have the same color. However, you can divide the set in different subsets and plot them each with their own color:

N = 100000;
x = rand(N,1);
y = rand(N,1);
C = sin(2*x)+y;

cdivs = 10;
[~, edges] = hist(C,cdivs-1);
edges = [-Inf edges Inf]; % to include all points
[Nk, bink] = histc(C,edges);

figure;
hold on;
cmap = jet(cdivs);
for ii=1:cdivs
    idx = bink==ii;
    plot(x(idx),y(idx),'.','MarkerSize',4,'Color',cmap(ii,:));
end

colormap(cmap)
caxis([min(C) max(C)])
colorbar

which responds already a lot better than scatter(x,y,1,C) which gives about the same plot, but with higher color resolution (which is adjustable in my code above).

这篇关于matlab:具有大量数据点的散点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆