如何生成等高线图?

发布于 2024-08-12 09:48:26 字数 304 浏览 5 评论 0原文

如何生成这样的等高线图: 轮廓 http://www.fz-juelich .de/vislab/software/gsharp/Gsharp/userguide/interpolate/ex6.gif

如果这些点位于规则网格上就很简单,但如果它们不是(就像我的示例中那样)怎么办?是否有一个相当简单的算法来确定每个像素的颜色?

How do I generate a contour graph like this:
contour http://www.fz-juelich.de/vislab/software/gsharp/Gsharp/userguide/interpolate/ex6.gif

It's easy enough if the points are on a regular grid, but what if they aren't, like in my example? Is there a fairly simple algorithm to determine the color for each pixel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

離殇 2024-08-19 09:48:26

也许有点晚了,

但是在较新版本的 matplotlib 中,您可以网格数据:

http://www .scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

也许有帮助

Maybe its a bit late,

however in the newer versions of matplotlib you can grid data:

http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

maybe it helps

装纯掩盖桑 2024-08-19 09:48:26

您可以使用许多插值算法来获取中间点。我在 GIS 中使用的一种是克里金算法,它看起来像您发布的数据使用类似的东西。 (您可以看出,因为例如“热黄色”点并不以黄色样本为中心,这就是线性插值的情况)

维基百科的双三次插值页面有一些关于选择不同插值效果的很好的示例。

不同的数据可能需要不同的插值。

然后使用 Gnuplot

如此处所述, 创建颜色轮廓。

看起来它可以处理非矩形数据,但我会测试这个假设。

示例:

示例 GnuPlot 轮廓图像
(来源:lanl.gov

There are lots of interpolation algorithms that you can use to get intermediate points. One I have used in GIS is the Kriging algorithm, and it looks like the data you posted uses something similar. (You can tell because the "hot yellow" spots for example are not centered on the yellow sample, which would be the case with linear interpolation)

Wikipedia's Bicubic Interpolation page has some nice examples of the effect of choosing a different interpolation.

Different data may require different interpolation.

Then use Gnuplot

as described here, to create color contours.

Looks like it can handle non-rectangular data, but I would test that assumption.

An example:

Example GnuPlot contour image
(source: lanl.gov)

终弃我 2024-08-19 09:48:26

来自此处

Origin 的 XYZ 等值线图可让您创建等值线图,而无需将 XYZ 数据转换为矩阵。它使用一种称为三角测量的插值形式。

三角剖分是将表面或平面多边形划分为一组三角形,通常有每个三角形边完全由两个相邻三角形共享的限制。三角剖分的另一个好处是能够处理稀疏以及不规则数据。

听起来很困难但可行。

From here

Origin’s XYZ Contour graph lets you create a contour plot without ever having to convert your XYZ data to a matrix. It uses a form of interpolation called triangulation.

Triangulation is the division of a surface or plane polygon into a set of triangles, usually with the restriction that each triangle side is entirely shared by two adjacent triangles.Triangulation has the added benefit of being able to handle sparse, as well as irregular data.

So sounds like difficult but doable.

夜清冷一曲。 2024-08-19 09:48:26

显示的图像不是传统的等高线图。本质上,如果该函数可以直接处理分散的数据,那么 matlab 可能会使用函数 pcolor 生成该函数。事实上,pcolor 只是冲浪,调用 view(0,90)。

如果您确实想查看等高线图,最简单的答案是使用 tricontour,在文件交换中找到。该工具将对分散的数据进行三角测量,然后生成等值线图。

如果您希望在分散的数据集上生成类似 pcolor 的解决方案,那么一个简单的解决方案是使用 delaunay 对数据进行三角测量,然后调用 trisurf。这些调用可能看起来模糊地像这样......

tri = delaunay(x,y);
trisurf(tri,x,y,z)
view(0,90)

不可否认,该解决方案不会为您提供原始图片中漂亮的圆形彩色域。为此,需要其他更复杂的解决方案。但由于我还不确定上面提出的解决方案是否可以接受,所以我现在就到此为止。

The image shown is not a traditional contour plot. It is essentially what matlab might produce with the function pcolor, if that function could work directly on scattered data. In fact though, pcolor is just surf, with a call to view(0,90).

If you really want to see a contour plot, the simplest answer is to use tricontour, found on the file exchange. This tool will triangulate the scattered data, then generate a contour plot.

If you wish to generate a pcolor-like solution on a scattered data set, then a simple solution is to use delaunay to triangulate the data, then call trisurf. The calls might look vaguely like this...

tri = delaunay(x,y);
trisurf(tri,x,y,z)
view(0,90)

Admittedly, that solution will not give you the nicely circular colored domain in the original picture. Other, more sophisticated solutions would be necessary for that. But since I'm not sure yet whether the solution I posed above would be acceptable, I'll stop here for now.

恰似旧人归 2024-08-19 09:48:26

查找二维插值。有一些简单的算法,但它们可能执行得不太好(或者需要很长时间来计算)。

Look up 2D interpolation. There are some simple algorithms, but they may not perform that well (or take a long time to calculate).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文