Plotting level curves (isocurves) with pyqtgraph

This is the place for queries that don't fit in any of the other categories.

Plotting level curves (isocurves) with pyqtgraph

Postby alexfrigo » Wed Sep 28, 2016 3:45 pm

Hi everyone.

I am trying to plot a red level curve at level=2 onto the surface z, which is defined by the following code.
I am able to visualize the background image, but I can't plot the red curve on it.
I have looking for tutorials and examples (isocurve.py included) for days, without any useful advice.
Can anybody please give me a piece of working code?

Thank you

Here's the code...

Code: Select all

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

grid
=np.linspace(0,6.28,30)
xx,yy=np.meshgrid(grid,grid)
z=np.sin(xx)+np.cos(yy)

window=pg.GraphicsWindow()
window.setWindowTitle('exampleisocurve')
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(c)

window.show()
sys.exit(app.exec_())
Last edited by micseydel on Wed Sep 28, 2016 3:58 pm, edited 1 time in total.
Reason: Initial post lock. [i] -> [code]
alexfrigo
 
Posts: 1
Joined: Wed Sep 28, 2016 3:31 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 11 guests