[vtkusers] R: Plot XY

edoardo.belletti at alice.it edoardo.belletti at alice.it
Sun Mar 28 14:32:20 EDT 2010


I don't have the latests CVS version of VTK but VTK 5.4.2 that I have download from www.vtk.org 
and so the code that you suggest me it doesn't  work because it don't found these files: 
vtkChartXY, vtkPlot.h.h, vtkContextView.h, vtkContextScene.h
There is some way to simply have a XYPlot of two vectors with my VTK release?

Thank you 
Edoardo

-----Messaggio originale-----
Da: daviddoria at gmail.com per conto di David Doria
Inviato: dom 28/03/2010 20.10
A: edoardo.belletti at alice.it
Cc: VTK_forum
Oggetto: Re: [vtkusers] Plot XY
 
On Sun, Mar 28, 2010 at 2:03 PM, <edoardo.belletti at alice.it> wrote:

>   Hello,
>
> I am new to VTK so please sorry if this problem is obvious.
>
> I am trying to use the XYPlotActor object to create a simply plot of one
> variable against another.
>
> I have found a piece of code in a past discussion and I have tried to run
> it but the problem is that it doesn't found the
> vtkFloatScalars.h file
> is there anything in particular that I should add in the CMakeLists.txt to
> include this library?
> the code is this:
>
> int main()
> {
>         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);
>         return 0;
> }
>
> Thank you very much for the interest
> Edoardo
>
>
> There is no file in the current CVS called vtkFloatScalars.h, so I'm
assuming that is very old code.

Marcus Hanwell has been working hard on new charting functionality - there
is a simple example here:
http://www.vtk.org/Wiki/VTK_Examples_Chart_XY

You must have the latests CVS version of VTK built to use this new feature.
<http://www.vtk.org/Wiki/VTK_Examples_Chart_XY>
Thanks,

David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100328/07064d63/attachment.htm>


More information about the vtkusers mailing list