[vtkusers] Help with vtkXYPlotActor

REGAT-BARREL Aurélien arbvtk at yahoo.fr
Fri May 14 16:54:20 EDT 2004


Hi,
I am also plotting points from a std::vector<float> with a vtkXYPlotActor.
My code looks like this :
 
std::vector<float> values;
/* ... */
vtkFloatArray * Xarray = vtkFloatArray::New();
vtkFloatArray * Yarray = vtkFloatArray::New();
 
Xarray->Initialize();
Yarray->Initialize();
for ( int i = 0; i < values.size(); ++i )
{
    Xarray->InsertNextValue( i );
    Yarray->InsertNextValue( values[ i ] );
}
vtkFieldData * FieldValues = vtkFieldData::New();
FieldValues->AllocateArrays( 2 );
FieldValues->AddArray( Xarray );
FieldValues->AddArray( Yarray );
vtkDataObject * Data = vtkDataObject::New();
Data->SetFieldData( FieldValues );
vtkXYPlotActor * XYplot = vtkXYPlotActor::New());
XYplot->AddDataObjectInput( Data );
XYplot->SetXValuesToValue();
XYplot->SetDataObjectXComponent( 0, 0 );
XYplot->SetDataObjectYComponent( 0, 1 );

But I have a problem.
When I want to change the viewed values, I do the same thing just after a XYplot->RemoveAllInputs(), but it crashes...
 
Hope this helps.

Curtis Cooper <curtis at hindmost.LPL.Arizona.EDU> wrote:
Hi,

I am interested in plotting pairs of input X, Y vectors using VTK, with
the ability to set the attributes of each dataset separately, as is done
in the example xyPlot.py.

My vectors start as STL vectors. How do I get that into the dataset
format understood by the vtkXYPlotActor class? For an example C++ usage,
I want to be able to do this:


vector x, y2, y3;

x.push_back(1); x.push_back(2); x.push_back(3);
x.push_back(4); x.push_back(5); x.push_back(6);

y2.push_back(1); y2.push_back(4); y2.push_back(9);
y2.push_back(16); y2.push_back(25); y2.push_back(36);

y3.push_back(1); y3.push_back(8); y.push_back(27);
y3.push_back(64); y3.push_back(125); y.push_back(216);

QueueVectorPair(x, y2);
QueueVectorPair(x, y3);

Plot();


Thanks,
Curtis

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

Aurélien REGAT-BARREL
		
---------------------------------
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040514/befc6f44/attachment.htm>


More information about the vtkusers mailing list