[vtkusers] Plot XY
David Doria
daviddoria+vtk at gmail.com
Sun Mar 28 14:10:24 EDT 2010
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/c12a470d/attachment.htm>
More information about the vtkusers
mailing list