Madz
Madz

Reputation: 1279

vtkAxis - remove decimal points from axis notation

I need to display the value of the axis without decimal points in a vtkChart.

eg- If I have values 2.31, 4.76, 7.39 etc.. I want to display them on the axis as 2, 5, 7. As integers and not as doubles or floats.

I tried using PRINTF_NOTATION on vtkAxis::SetNotation(int notation), but it would display a single decimal point. Is there a way to achieve this in my chart using vtkAxis?

Any help would be appreciated. Thanks.

Upvotes: 0

Views: 208

Answers (1)

Taron
Taron

Reputation: 1235

mululu's comment is correct. It should work with SetLabelFormat("%1.0f"), but only with certain tick settings and notation according to the vtkAxis::SetLabelFormat documentation

Get/Set the printf-style format string used when TickLabelAlgorithm is TICK_SIMPLE and Notation is PRINTF_NOTATION.

I tried the following and it worked for me. vtk 8.0 on windows:

axis->SetNotation( vtkAxis::PRINTF_NOTATION );
axis->SetTickLabelAlgorithm( vtkAxis::TICK_SIMPLE );
axis->SetLabelFormat("%1.0f");

Upvotes: 1

Related Questions