[Paraview] 2D Plotting

Herbert Mullens herbert.mullens at imts.us
Tue Apr 29 13:46:40 EDT 2008


I am writing a custom reader for a client that needs to display an XY Plot for a given time step.  I am reading in their data from a text file and outputting a vtkRectilinearGrid data object.  I am currently having two issues.  

The first issue is that I can not get the plot to use the correct array as the X coordinates.  The data has three arrays, stress, strain, and time.  I want to plot stress versus strain.  Setting the time array as the X Coordinate uses the time values as my x axis, but setting any other array as the X coordinate results in the Y axis array's index being used.  

The second issue is that the range of the axes change based off of the range of the data that is currently loaded.  I would like the range on the axes to stay constant for every time step.  The effect they want is one of the plot being drawn as the time step changes.  With the range changing every step the results look confusing.  Is there any way to change this behavior?

Any help that can be offered will be greatly appreciated.  I am including a code snippet below from the RequestData method of my class showing the code that creates, fills, and uses the arrays.

Thank you,
Herb

------------------------ Begin code snippet-------------------------------
	output->SetDimensions(this->numberOfTimeSteps,  1, 1);
	
	vtkDoubleArray* stress_data = vtkDoubleArray::New();
	vtkDoubleArray* strain_data = vtkDoubleArray::New();
	vtkDoubleArray* time_data = vtkDoubleArray::New();
	
	vtkPointData* points = output->GetPointData();
	
	stress_data->SetName("Stress");
	stress_data->SetNumberOfComponents(1);
	stress_data->SetNumberOfTuples(requested_time_step);
	
	strain_data->SetName("Strain");
	strain_data->SetNumberOfComponents(1);
	strain_data->SetNumberOfTuples(requested_time_step);
	
	time_data->SetName("Time");
	time_data->SetNumberOfComponents(1);
	time_data->SetNumberOfTuples(requested_time_step);
	
	// Create dummy array for y and z values
	vtkDoubleArray* empty = vtkDoubleArray::New();
	
	empty->SetNumberOfComponents(1);
	empty->SetNumberOfTuples(1);
	empty->SetTuple1(0, 0.0);
	
	output->SetYCoordinates(empty);
	output->SetZCoordinates(empty);
	
	// Fill in the data arrays.
	// Now start processing data and writing it to the vtkDoubleArrays.
	double stress_temp, strain_temp;
	
	for ( int i = 0; i <= requested_time_step; i++ )
	{
		file >> stress_temp >> strain_temp;

		time_data->SetTuple1(i, i);
		stress_data->SetTuple1(i, stress_temp);
		strain_data->SetTuple1(i, strain_temp);
	}
	
	points->AddArray(time_data);
	points->AddArray(stress_data);
	points->AddArray(strain_data);
	
	output->SetXCoordinates(stress_data);
	
	time_data->Delete();
	stress_data->Delete();
	strain_data->Delete();
	empty->Delete();
------------------------ End code snippet---------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20080429/bf71ca42/attachment.htm>


More information about the ParaView mailing list