XYPlotActor

Steve Guerrero guerrero at gene.com
Mon Nov 29 19:11:45 EST 1999


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.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list