Python Forum

Full Version: Plotting level curves (isocurves) with pyqtgraph
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I am trying to plot a red loop (isocurve) that correspond to the level z=2 of a given surface. Maybe I am able to create the isocurve, but I cannot overlap it to the grayscale image. (Output image)
I have been trying for days, but wasn't able to find any working example on the internet (isocurve.py included).
Can anybody provide me a working piece of code?

Thank you very much.

Here's the code.

from pyqtgraph.Qt import QtGui,QtCore
import numpy as np
import pyqtgraph as pg
import sys

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)

window=pg.GraphicsWindow()
window.setWindowTitle('isocurve example')
vb=window.addViewBox()
img=pg.ImageItem(z)
vb.addItem(img)
vb.setAspectLocked()

c=pg.IsocurveItem(level=2,pen='b')
c.setParentItem(img)
c.setZValue(0.5)
vb.addItem©


window.show()
sys.exit(app.exec_())


I forgot to say that I am forced to use the library pyqtgraph.
matplotlib solutions are not allowed.
Since this is relatively specialized, you might want to try a more specialized community. If you do find the answer though, we'd definitely be curious about the solution!