[vtkusers] Setting axis text label orientation in vtkChartXY
Steven Chall
stevec at renci.org
Tue Mar 8 15:03:38 EST 2011
On 7 March 2011 17:25, Eric E. Monson <emonson at cs.duke.edu> wrote:
...
> Regarding the font size and tick spacing, you can get around this problem in a manual way by specifying the tick positions and labels and their font sizes. vtkAxis has SetTickPositions() and SetTickLabels(), both of which internally set Behavior = 2 (CUSTOM), which turns off automatic tick spacing calculations. Then you can use GetLabelProperties() to set the font size to a reasonable one for the image size you want. It's not a very automatic solution, but it gets around the problem.
...
Here's an apparently similar situation: For the vertical axis in vtkChartXY the default text orientation is vertical. I'd like to set it to horizontal, i.e., the usual way to place text. For vtkChartXY *chart, I call:
chart->GetAxis(vtkAxis::LEFT)->GetTitleProperties()->SetOrientation(90.0);
which does nothing right now, for any orientation values, although the orientation is apparently actually being set, since:
double yOr = chart->GetAxis(vtkAxis::LEFT)->GetTitleProperties()->GetOrientation();
always sets yOr to the expected orientation value, and even though I *think* I'm (inadvertently) following Eric's recommendation for setting Behavior = 2 (CUSTOM) by first doing this (turning off ticks and tick labels by using instantiated but empty vtkDoubleArray *tickPositions and vtkStringArray *tickLabels as args, since chart->GetAxis(vtkAxis::LEFT)->SetNumberOfTicks(0) doesn't seem to do anything, either) :
chart->GetAxis(vtkAxis::LEFT)->SetTickPositions(tickPositions);
chart->GetAxis(vtkAxis::LEFT)->SetTickLabels(tickLabels);
Furthermore, this, called right after SetOrientation(...), *does* work:
chart->GetAxis(vtkAxis::LEFT)->GetTitleProperties()->SetLineOffset(-193);
Now I just noticed that I'm using [GS]etTitleProperties() instead of [GS]etLabelProperties() as in Eric's email, so I replaced all of the former with the latter, and got the same results, with one exception: ...->SetLineOffset(-193) no longer seems to work, either.
Thanks for any suggestions you may have.
Steve
-Steve Chall
Senior Research Software Developer
Renaissance Computing Institute (RENCI)
Phone: 919-681-9639
Email: stevec at renci.org
More information about the vtkusers
mailing list