无序 XY 坐标对 +浓度等高线图
我有 2 个向量,X 和 Y,对应于无序坐标列表,以及每个点对应的浓度向量 C。
我想将其绘制在结构化网格上作为二维等高线图。
scatter3(X,Y,C,[],C);
给了我我想要的视觉效果,但我正在寻找 2D 轮廓,即 pcolor
。有没有像 griddata 或 trigriddata 这样的简单解决方案?
编辑:好的,所以 `scatter3(X,Y,C,[],C); view([0 90])´ 是正确的视觉效果。 TriScatteredInterp 对于矩形效果很好。但是像地图这样的不规则形状呢? :=)
F = TriScatteredInterp(x,y,C);
ty=0:0.005:0.284;
tx=0:0.005:0.65;
[qx,qy] = meshgrid(tx,ty);
qC = F(qx,qy);
pcolor(qx,qy,qC);
示例:(X=宽度坐标,Y=高度坐标,C=污染物浓度)
X Y C
0.1 0.0 5
0.1 0.1 10
0.1 0.21 5
0.2 0.1 4
0.2 0.3 1
0.2 0.5 2
0.2 0.51 7
0.3 0.15 4
0.3 0.36 6
0.3 0.5 3
0.3 0.52 7
scatter3(X,Y,C,[],C,'filled'); %individual plotting of X,Y pairs and colors=C
view([0 90]) %see only XY and Z becomes flat
假设我们有 10000 个 XY 对,因此 scatter3
生成几乎一个图像
,但没有插值。
I have 2 vectors, X and Y, corresponding to a list of unordered coordinates, and a corresponding concentration vector C for each point.
I'd like to plot this on a structured grid as a 2D contour plot.
scatter3(X,Y,C,[],C);
gives me what I want visually, but I'm looking for 2D contours, i.e. pcolor
. Is there an easy solution like griddata or trigriddata?
EDIT: Ok, so `scatter3(X,Y,C,[],C); view([0 90])´ is the correct visual.
TriScatteredInterp works nicely for a rectangle. But what about an irregular shape like a map? :=)
F = TriScatteredInterp(x,y,C);
ty=0:0.005:0.284;
tx=0:0.005:0.65;
[qx,qy] = meshgrid(tx,ty);
qC = F(qx,qy);
pcolor(qx,qy,qC);
EXAMPLE: (X=width coordinate , Y= height coordinate, C= concentration of pollutant)
X Y C
0.1 0.0 5
0.1 0.1 10
0.1 0.21 5
0.2 0.1 4
0.2 0.3 1
0.2 0.5 2
0.2 0.51 7
0.3 0.15 4
0.3 0.36 6
0.3 0.5 3
0.3 0.52 7
scatter3(X,Y,C,[],C,'filled'); %individual plotting of X,Y pairs and colors=C
view([0 90]) %see only XY and Z becomes flat
Imagine we had 10000 XY pairs so scatter3
produces almost an image
but without interpolation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,您可以使用
contour(X,Y,Z)
编辑:您可以将
imagesc
与您自己制作的矩阵一起使用。因此,如果您的x
和y
值在合理的范围内,您可以从以下开始:If I understand your question correctly you can use
contour(X,Y,Z)
EDIT: You can use
imagesc
with a matrix that you make yourself. So if yourx
andy
values are in a reasonable range you can just start with: