您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – 从matplotlib的轮廓中获取坐标?

5b51 2022/1/14 8:22:26 python 字数 2726 阅读 574 来源 www.jb51.cc/python

背景 从the documentation example here开始,可以使用代码段轻松生成以下等高线图. import matplotlib import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab import matplotlib.pyplot as plt matplotlib.rcPar

概述

the documentation example here开始,可以使用代码段轻松生成以下等高线图.

import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'

delta = 0.025
x = np.arange(-3.0,3.0,delta)
y = np.arange(-2.0,2.0,delta)
X,Y = np.meshgrid(x,y)
Z1 = mlab.bivariate_normal(X,Y,1.0,0.0,0.0)
Z2 = mlab.bivariate_normal(X,1.5,0.5,1,1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)

# Create a simple contour plot with labels using default colors.  The
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour,removing the lines beneath
# the label
plt.figure()
CS = plt.contour(X,Z)
plt.clabel(CS,inline=1,fontsize=10)
plt.title('Simplest default with labels')

我的目标

我已经获得了我的等高线图,同时得到了matplotlib.contour.QuadContourSet实例CS.在示例代码段中,CS仅用于clabel().但是对于我的情况,我需要获得轮廓线的方程或坐标集以进一步计算.

如何从实例CS中提取轮廓线的坐标?要么
我怎样才能以其他方式实现它?

我打赌必须有办法这样做.否则,轮廓事物只是一个“可视化的花瓶”.

尝试:

dat0= CS.allsegs[0][0]
plt.plot(dat0[:,0],dat0[:,1])

绘制第一个(-1)轮廓水平.

总结

以上是编程之家为你收集整理的python – 从matplotlib的轮廓中获取坐标?全部内容,希望文章能够帮你解决python – 从matplotlib的轮廓中获取坐标?所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶