[vtkusers] Setting axis text label orientation in vtkChartXY
Steven Chall
stevec at renci.org
Wed Mar 9 11:29:06 EST 2011
Marcus,
Thanks for your email. I'm using 5.6.1, so I guess that explains it: I'm trying to use functionality that's not in this release. Looking forward to 5.8.
-Steve
-----Original Message-----
From: Marcus D. Hanwell [mailto:marcus.hanwell at kitware.com]
Sent: Wednesday, March 09, 2011 11:25 AM
To: Steven Chall
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Setting axis text label orientation in vtkChartXY
On Tue, Mar 8, 2011 at 3:03 PM, Steven Chall <stevec at renci.org> wrote:
> 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(-19
> 3);
>
> 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.
>
Which version of VTK are you using here? I went through the vtkAxis class to ensure that the text properties are used, and these fixes will be in the VTK 5.8 release. I don't think they were in VTK 5.6.1 if you are using the previous release of VTK. If there is anything I missed then it is a bug, and I will fix it.
Marcus
More information about the vtkusers
mailing list