level curves with pyqtgraph: isocurve
<p>Does anybody know a way to obtain this (<a href="http://i.stack.imgur.com/SZLIl.png" rel="nofollow">level curves from matplotlib</a>) using isocurve from pyqtgraph?
Here's my code...</p>

<p>Thank you!</p>

<pre><code>from pyqtgraph.Qt import QtGui,QtCore
import numpy as np
import pyqtgraph as pg
import sys

#data creation
app=QtGui.QApplication([])
x = np.linspace(0,6.28,30)
y = x[:]
xx,yy = np.meshgrid(x,y)
z = np.sin(xx)+np.cos(yy)

win = pg.GraphicsWindow()
win.setWindowTitle('esempio isocurve')
vb = win.addViewBox()
img = pg.ImageItem(z)
vb.addItem(img) #visualizes img in viewbox vb
vb.setAspectLocked() #set img proportions (?)

c = pg.IsocurveItem(data=z,level=2,pen='r')
c.setParentItem(img) #set img as parent of the isocurve item c (?)
c.setZValue(10) #I DO NOT KNOW THE MEANING OF THIS, JUST COPIED FROM THE EXAMPLE isocurve.py

vb.addItem(c)

win.show()
sys.exit(app.exec_())
</code></pre>

<p>[SOLVED] I had to edit the "functions.py" at row ~1500 in order to get rid of the error</p>

<pre><code>"TypeError: Cannot cast ufunc add output from dtype('int32') to dtype('uint8') with casting rule 'same_kind'".
</code></pre>

<p>The file "functions.py" is located in
C:\Users\my_name\AppData\Local\Programs\Python\Python35\Lib\site-packages\pyqtgraph (the windows search engine did not find it, as it was located inside a hidden folder!). Here's the modification suggested by <a href="https://groups.google.com/forum/#!topic/pyqtgraph/sG6NrMeHEwI" rel="nofollow">this Google Group</a>:</p>

<pre><code>index += (fields[i,j] * 2**vertIndex)
</code></pre>

<p>becomes</p>

<pre><code>index += (fields[i,j] * 2**vertIndex).astype(np.ubyte).
</code></pre>

<p>In my code, i had to set</p>

<pre><code>level=0
</code></pre>

<p>instead of</p>

<pre><code>level=2
</code></pre>

<p>, as 2 was greater than the maximum value of z. In other words, I was trying to draw a  2000m level curve for a 1500m mountain. Always remember to provide an appropriate level!!! <a href="http://i.stack.imgur.com/sxqs2.png" rel="nofollow">Here's the correct output</a> (-.-')</p>

python surface level pyqtgraph