[vtkusers] Setting the X axis of VtkChartsXY

Marcus D. Hanwell marcus.hanwell at kitware.com
Wed Mar 14 09:57:00 EDT 2012


On Sun, Mar 11, 2012 at 5:52 PM, Darshan Pai <darshanpai at gmail.com> wrote:
> I have a a set of Ids which are strings . Sample :- ( FP1,FP2.....
> FP10,AP1,AP2....AP10) etc
> For each ID I have a double value .
> I want to map the strings to the X-axis in the same order that I see the
> strings. I have all this information in a vtkTable.
> How do I arrange the vtkChartXY to do precisely this .
>
Any axis on a chart can have custom labels. I notice now that there is
no test, but this can be done from ParaView for example.

vtkAxis *axis = chart->GetAxis(vtkAxis::BOTTOM);
axis->SetBehavior(vtkAxis::CUSTOM);
axis->SetTickPositions(positions);
axis->SetTickLabels(labels);

You would need a vtkDoubleArray with the label positions, and a
vtkStringArray with the custom labels. They should both be of the same
length.

Thanks,

Marcus



More information about the vtkusers mailing list