[vtkusers] vtkXYPlotActor problems

jafoster at uncc.edu jafoster at uncc.edu
Tue Feb 11 20:24:45 EST 2003


Hello all,

I am trying to use vtkXYPlotActor to plot some scalars.  I understand you have 
to provide a dataset containing scalar and point data, so I used a 
vtkStructuredGrid and set the point data to a vtkFloatArray.  I don't really 
use the structured grid points; I just want to plot index of each point on 
the x-axis and the corresponding scalar value (from the float array) on the 
y-axis.  This is what I have:

//////////////////////////////////

vtkStructuredGrid *sgrid = vtkStructuredGrid::New();
sgrid->SetDimensions( 100, 0, 0 );

vtkFloatArray *values = vtkFloatArray::New();

vtkPoints *points = vtkPoints::New();
points->Allocate( 100 );

float x[3] = {0., 0., 0.};

for( int i=0; i<100; i++ )
{
  points->InsertPoint( i, x );
  values->InsertNextValue( i/100. );
}

sgrid->SetPoints( points );
sgrid->GetPointData()->SetScalars( values );

vtkXYPlotActor *plot = vtkXYPlotActor::New();
plot->AddInput( sgrid );
plot->SetXValuesToIndex();
plot->SetDataPlotModeToRows();
plot->SetPlotPoints( 0, 1 );

ren->AddActor2D( plot );

//////////////////////////////////////

vtkXYPlot actor keeps telling me there's no scalar data to plot.  But I used 
SetScalars to attach my float array; I just don't get it!  Can someone help?

Thanks,
  Joshua Foster


---------------------------------------------
This message was sent using Mosaic Webmail.
http://www.coe.uncc.edu/mosaic/





More information about the vtkusers mailing list