[vtkusers] Setting properties for vtkXYPlotActpr axis text properties
Steve Chall
stevec at renci.org
Thu Sep 24 13:14:58 EDT 2009
I'm trying to set text color, font size, and orientation on the titles nd
labels to the axes for a vtkXYPlotActor. I'm writing in C++ using VTK 5.0
in Ubuntu 8.04.1. Here's the code fragment:
vtkXYPlotActor *plot = vtkXYPlotActor::New();
plot->GetYAxisActor2D()->GetTitleTextProperty()->SetOrientation(-60.0);
double yAxisO =
plot->GetYAxisActor2D()->GetTitleTextProperty()->GetOrientation();
plot->GetYAxisActor2D()->GetTitleTextProperty()->SetColor(1.0, 1.0, 0.0);
double r = 77.0, g = 88.0, b = 99.0;
plot->GetYAxisActor2D()->GetTitleTextProperty()->GetColor(r, g, b);
plot->GetYAxisActor2D()->GetTitleTextProperty()->SetFontSize(4);
int fs = plot->GetYAxisActor2D()->GetTitleTextProperty()->GetFontSize();
cout << "yAxisO: " << yAxisO << "; fs: " << fs
<< "; r, g, b: " << r << ", " << g << ", " << b << endl;
And here's the output:
yAxisO: -60; fs: 4; r, g, b: 1, 1, 0
So, by returning them on request, the vtkTextProperty associated with the
Y-axis is returning values as though it's assigning them correctly for
orientation, font size, and color. However, nothing changes in the graph
display. The label stays white and horizontal and the font size remains the
default 12.
As an alternative I tried this code:
vtkTextProperty *p = vtkTextProperty::New();
p->SetColor(1.0, 1.0, 0.0);
p->SetOrientation(-60.0);
p->SetFontSize(2);
plot->SetAxisLabelTextProperty(p);
plot->SetAxisTitleTextProperty(p);
cout << "yAxisO: " << yAxisO
<< "; r, g, b: " << r << ", " << g << ", " << b << endl;
int fontSize = p->GetFontSize();
cout << "fontSize: " << fontSize << endl;
With this output:
yAxisO: -60; r, g, b: 1, 1, 0
fontSize: 2
This time the font color changed to yellow as I'd requested for titles and
labels on both axes. But again no change in orientation or fontSize.
Is there yet another approach that *will* give me control over axis
properties? Thanks.
-Steve Chall
Senior Research Software Developer
Renaissance Computing Institute
Phone: 919-515-0051
Email: stevec at renci.org
More information about the vtkusers
mailing list