Python - 如何将 'boundary edge' 绘制到 2D 绘图上

标签 python matplotlib plot

下面的程序pastebinned生成一个如下所示的图: Original plot Pastebin:http://pastebin.com/wNgAG6K9

基本上,该程序求解 AA 的方程,并绘制 AA>0 和 AA=/=0 的值。使用 pcolormesh 从 3 个名为 xyz 的数组绘制数据(第 57 - 59 行)。

我想做的事情:

我想在边界周围绘制一条线,其中解从零(黑色)到非零(黄色/绿色),请参见下图。解决这个问题最明智的方法是什么?

即红色线条(用MS Paint粗略地完成)

enter image description here

更多信息:我需要能够存储红色虚线边界值,以便可以将红色虚线边界条件绘制到由实际/测量/非理论数据制作的另一个二维图上。

欢迎询问更多信息。

最佳答案

在没有看到您的数据的情况下,我建议首先尝试使用 matplotlib 的内部算法来绘制 contour线对应于零电平。这很简单,但可能会发生用于此目的的插值看起来不够好的情况(我不知道它是否可以找到轮廓线中的尖锐峰值)。布丁的证明就在吃中:

plt.contour(x,y,z,[0],colors='r',linewidths=2,linestyles='dashed')

如果这还不够,您可能必须求助于图像处理方法来找到数据的边界(在将其转换为二进制之后)。

关于Python - 如何将 'boundary edge' 绘制到 2D 绘图上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39809997/

相关文章:

python - 未找到 Virtualenv 命令

python - python - 如何在python的csv文件中为每个基因保留x个最高人相关值的基因对?

python - openAI DALL-E ModuleNotFoundError

Python请求: Anyway to download just the body of a get response?

python - Matplotlib 错误类型错误 : Cannot cast array data from dtype ('float64' ) to dtype ('<U32' ) according to the rule 'safe'

r - 在 R 中绘制 shapefile 中的元素

python - 消除小于某个指定数量阈值的连接像素数量

python - 使用 scikit 包在 Python 中绘制集群区域的边界

python - 如何聚合和绘制 pandas 数据框中的数据?

r - 设置带有刻度的分类轴标签 "free"ggplot2