[vtkusers] reversing axes in vtkXYPlotActor - more information
Rebecca Savage
Rebecca.Savage at sea.co.uk
Tue Dec 17 05:23:26 EST 2002
Dear users,
I'll try again with some more information!
I am using vtkXYPlotActor to display simple plots. In some cases I want to reverse the Y axis, so immediately after creating a vtkXYPlotActor instance, I call the SetReverseYAxis function on it, with the variable set to true. The labels along the y axis are reversed as required, but the data displayed on it is not. Thus the axes no longer match the data. This wasn't what I was expecting - in Matlab for example the data would also be reversed. In VTK is this the intended behaviour or have I missed something out?
The help wasn't particularly helpful:
"ReverseYAxisOn()
Normally the y-axis is plotted from minimum to maximum. Setting this instance variable causes the y-axis to be plotted from maximum to minimum. Note that boolean always applies to the y-axis even if ExchangeAxes is set."
Taken literally this means that only the axis and not the data is reversed?
If the data isn't reversed, has anyone written the code that will do it? If not I'll have to!
I am using VTK version 4.0.
Thanks for any ideas,
Rebecca Savage
// Sample code
//------------------------------------------------------------------------------------------------
// class members
vector<vtkRectilinearGrid*> m_rectGrids;
vtkXYPlotActor* m_pPlotActor;
//------------------------------------------------------------------------------------------------
// executable code
// create the line graph
m_pPlotActor = vtkXYPlotActor::New();
m_pPlotActor->SetXValuesToValue();
m_pPlotActor->SetReverseYAxis(true);
// add the input data in rectilinear grid format
m_rectGrids.resize(1);
m_rectGrids[0] = vtkRectilinearGrid::New();
m_rectGrids[0]->SetDimensions(2,1,1);
vector<double> xValues;
xValues.push_back(0);
xValues.push_back(1);
vector<double> yValues;
yValues.push_back(10);
yVales.push_back(20);
m_rectGrids[0]->SetXCoordinates(xValues);
m_rectGrids[0]->GetPointData()->SetScalars(yValues);
for (unsigned long i = 0; i < m_rectGrids.size(); i++)
m_pPlotActor->AddInput(m_rectGrids.at(i));
// add actor to window
m_pRen->AddActor(m_pPlotActor);
etc....
More information about the vtkusers
mailing list