[vtkusers] XYPlot from non-VTK data source
Pieper, Chris
cpieper at kcc.com
Thu Sep 7 09:57:27 EDT 2006
I apologize if this is a basic question but I was unable to find the
information I need by searching the mail archive...
I would like to make a very basic XY plot where I have X and Y data in
two Python lists. I have seen some examples that are apparently quite
dated (from 1999) and no longer apply to modern versions of VTK.
Can someone point me to a reference or comment on what the basic
strategy to generate an XY plot from a non-VTK datasource?
Here is what I'm trying to do, anyone in the know will quickly see that
this is wrong and doesn't work... Can someone get me on track? --
Thanks!
import vtk
x=[0., .5, 1.5, 2.7, 8.2, 9.3]
y=[0., 1.3, 2.9, 5.6, 7.3, 8.7]
z=[0., 0., 0., 0., 0., 0.]
N=len(x)
curve1=vtk.vtkRectilinearGrid()
curve1.SetDimensions(N,1,1)
dataValues=vtk.vtkFloatArray()
xCoords=vtk.vtkFloatArray()
zCoords=vtk.vtkFloatArray()
for i in range(N):
dataValues.InsertNextTuple1(y[i])
xCoords.InsertNextTuple1(x[i])
zCoords.InsertNextTuple1(z[i])
curve1.SetXCoordinates(xCoords)
curve1.SetYCoordinates(dataValues)
curve1.SetZCoordinates(zCoords)
xyPlot=vtk.vtkXYPlotActor()
xyPlot.SetXValuesToArcLength()
xyPlot.AddInput(curve1)
ren = vtk.vtkRenderer()
ren.SetBackground(1,1,.9)
renWin = vtk.vtkRenderWindow()
renWin.SetSize(600, 400)
renWin.AddRenderer(ren)
ren.AddActor(xyPlot)
renWin.Render()
This e-mail is intended for the use of the addressee(s) only and may contain privileged, confidential, or proprietary information that is exempt from disclosure under law. If you have received this message in error, please inform us promptly by reply e-mail, then delete the e-mail and destroy any printed copy. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060907/f28c74fc/attachment.htm>
More information about the vtkusers
mailing list