我需要从等高线图中提取数据点。我已经完成以下操作:matplotlib - extracting data from contour lines
但是几个星期前,我更新了python,现在代码无法运行。我已验证尝试运行可以正常运行的旧代码,并且它也收到错误消息。
下面是代码示例:
%matplotlib inline
from numpy import arange
from numpy import pi
import matplotlib.pyplot as plt
import numpy as np
pos = np.logspace(-5,-1,10)
tends = np.logspace(-4,-1,10)
zz = [f(p,t) for p in pos for t in tends]
zz = np.reshape(zz,(ii,ii))
plt.xscale('log')
plt.yscale('log')
cs = plt.contour(pos,tends,zz,1)
p = cs.collections[0].get_paths()[0]
v = p.vertices
xcol1 = v[:,0]
ycol2 = v[:,1]
,错误是:
IndexError Traceback (most recent call last)
<ipython-input-153-3cef0e58f7bb> in <module>
2 plt.yscale('log')
3 cs = plt.contour(pos,Tends,zz,1)
----> 4 p = cs.collections[0].get_paths()[0]
5 v = p.vertices
6 xcol1 = v[:,0]
IndexError: list index out of range
我试图做:
p = cs.collections[0].get_paths()
但是它返回p为[]空。所以,我不知道该怎么办,对此我不是很熟悉。
谢谢!