XYPlotActor ARHHHG!
Miller, James V (CRD)
millerjv at crd.ge.com
Tue Nov 30 07:53:16 EST 1999
The XYPlotActor has several modes for handling the X data. The default is to used the ptIds as the
independent variable. There is another mode which is based on arc length (which will work fine for
your case). However, there is a bug in the code currently (I shoul be checking in a fix today).
If you cannot wait, edit imaging/vtkXYPlotActor.cxx and everywhere there is a
vtkMath::Distance2BetweenPoints(...) call, surround it with a square root, i.e. sqrt(
vtkMath::Distance2BetweenPoints(...) )
> -----Original Message-----
> From: Steve Guerrero [mailto:guerrero at gene.com]
> Sent: Monday, November 29, 1999 8:36 PM
> To: VTK
> Subject: Re: XYPlotActor ARHHHG!
>
>
>
> Correction, it doesn't work. Anybody know how to do what I
> mention below?
>
> Steve Guerrero wrote:
>
> > Doh!
> >
> > Please disregard this question, I found the problem.
> >
> > The approach below does seem to work, unfortunately, it
> looks like the x-axis
> > labels don't get updated (either that, or they are supposed
> to be manually set).
> >
> > -Steve Guerrero
> >
> > Steve Guerrero wrote:
> >
> > > Hello,
> > >
> > > I am new to VTK so please forgive me if this is obvious.
> > >
> > > I am trying to use the XYPlotActor object to create a
> simply plot of one
> > > variable against another.
> > >
> > > For example:
> > > x = [0, 1.5, 6.2, 10.2]
> > > y = [8, 9.3, 10.9, 27]
> > >
> > > I would like to plot y as a function of x,
> > >
> > > I tried the approach below but it does not seem to work.
> My approach
> > > was to create a 1 dimensional rectilinear grid data set
> and set the
> > > Xcoordinates to the vector given above. The Y data looks fine.
> > > Unfortunately, the X axis seems to be the point IDs as
> opposed to the
> > > values in the vector above. Is this the wrong approach?
> Any help
> > > would be appreciated.
> > >
> > > Thanks,
> > > -Steve Guerrero
> > >
> > > int dataSize = 4;
> > > float x[4] = { 0, 1.5, 6.2, 10.2 };
> > > float y[4] = {8, 9.3, 10.9, 27};
> > > vtkRectilinearGrid *curve1 = vtkRectilinearGrid::New();
> > > curve1->SetDimensions(dataSize,1,1);
> > > vtkFloatScalars *dataValues = vtkFloatScalars::New();
> > > vtkFloatScalars *xCoords = vtkFloatScalars::New();
> > >
> > > int w;
> > > for(w=0; w<dataSize; w++)
> > > {
> > > dataValues->InsertScalar(w, y[w]);
> > > xCoords->InsertScalar(w, x[w]);
> > > }
> > >
> > > curve1->SetXCoordinates(xCoords);
> > > curve1->GetPointData()->SetScalars(dataValues);
> > >
> > > vtkXYPlotActor *theXYPlot = vtkXYPlotActor::New();
> > > theXYPlot->SetXValuesToArcLength();
> > > theXYPlot->AddInput(curve1);
> > >
> > >
> --------------------------------------------------------------
> ---------------
> > > This is the private VTK discussion list. Please keep
> messages on-topic.
> > > Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> > > To UNSUBSCRIBE, send message body containing "unsubscribe
> vtkusers" to
> > > <majordomo at gsao.med.ge.com>. For help, send message body
> containing
> > > "info vtkusers" to the same address. Live long and prosper.
> > >
> --------------------------------------------------------------
> ---------------
> >
> >
> --------------------------------------------------------------
> ---------------
> > This is the private VTK discussion list. Please keep
> messages on-topic.
> > Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> > To UNSUBSCRIBE, send message body containing "unsubscribe
> vtkusers" to
> > <majordomo at gsao.med.ge.com>. For help, send message body containing
> > "info vtkusers" to the same address. Live long and prosper.
> >
> --------------------------------------------------------------
> ---------------
>
>
>
> --------------------------------------------------------------
> ---------------
> This is the private VTK discussion list. Please keep
> messages on-topic.
> Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> <majordomo at gsao.med.ge.com>. For help, send message body containing
> "info vtkusers" to the same address. Live long and prosper.
> --------------------------------------------------------------
> ---------------
>
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list