[vtkusers] multiple xy plots?

Emiliano Beronich emiliano at veccsa.com
Mon Aug 23 10:56:24 EDT 2004


Hi Davis,

You can use vtkXYPlotActor to show two or more sets of data. You can add 
a set of data with the code shown below. This is the basic code to add 
only one set. You can adapt it to add two o more sets.

   Data = vtkPolyData::New();
   vtkPoints *points = vtkPoints::New();
   vtkFloatArray *scalars = vtkFloatArray::New();
   int numberofpoints = 400;
   int MaxT = 1;
   int MinT = 0;
   for (int i = 0; i <= numberofpoints; i++ ) {
     float x[3] = {i, 0, 0};
     float y = i;
     points->InsertPoint(i, x);
     scalars->InsertTuple1(i, y);
   }

   Data->SetPoints(points);
   Data->GetPointData()->SetScalars(scalars);
   points->Delete();
   scalars->Delete();
   XYPlot->AddInput(Data);
   Data->Delete();

But I have found troubles when I want to remove a curve. I have found a 
bug on vtkXYPlotActor class on the method RemoveInput that may need to 
be fixed. I attach the modified class that fix this problem.

Regards,
Emiliano



David Bernstein wrote:

> 
> Hi All, Can someone post a simple C++ example showing how to get two or 
> more
> sets of data plotted in the same X-Y plot?  I'm importing the data in 
> the form of
> stl vectors.
> 
> Thanks,
> Dave Bernstein
> 
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vtkXYPlotActor.cxx
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040823/4533888a/attachment.asc>


More information about the vtkusers mailing list