0

I need to extract data points from a contour plot. I have already done this following: matplotlib - extracting data from contour lines

But a few weeks ago, I updated python, and now the code won't run. I verified trying to run an old code that worked properly, and it is also getting error message.

Here is an example of the code:

%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]

and the error is:

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

I tried to do:

p = cs.collections[0].get_paths()

But it returned that p was [] empty. So, I don't know what else to do, I'm not very familiar with this.

Thanks in advance!

Ah77
  • 85
  • 1
  • 9

0 Answers0