[vtkusers] Plot XY

edoardo.belletti at alice.it edoardo.belletti at alice.it
Sun Mar 28 14:03:01 EDT 2010


 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100328/41630529/attachment.htm>


More information about the vtkusers mailing list