2014-12-13 4 views
0

레이블 끝에 축 레이블을 그릴 수 있습니까? 자세한 내용은 참조 사진 :vtk 차트 - 축 레이블의 끝에 축 레이블을 그리는 방법은 무엇입니까?

http://habrastorage.org/files/94f/41a/b18/94f41ab1897a4bde815644bf287b4af9.png

가능한 경우, 어떻게? 플로팅

vtkNew<vtkContextView> contextView; 

vtkNew<vtkTable> table; 
vtkNew<vtkChartXY> chart; 
vtkNew<vtkDoubleArray> timeAxis; 
vtkNew<vtkDoubleArray> realDataAxis; 
vtkNew<vtkDoubleArray> measuredDataAxis; 

// ... 

contextView->SetInteractor(vtkWidget->GetInteractor()); 
vtkWidget->SetRenderWindow(contextView->GetRenderWindow()); 

timeAxis->SetName("t"); 
realDataAxis->SetName("x(t)"); 
measuredDataAxis->SetName("x*(t)"); 

table->AddColumn(timeAxis.Get()); 
table->AddColumn(realDataAxis.Get()); 
table->AddColumn(measuredDataAxis.Get()); 

chart->SetShowLegend(true); 
auto legend = chart->GetLegend(); 
legend->GetLabelProperties()->SetFontSize(14); 
legend->GetLabelProperties()->SetFontFamilyToTimes(); 

auto xAxis = chart->GetAxis(vtkAxis::BOTTOM); 
xAxis->SetTitle(QApplication::translate("DataSetChartWidget", "t").toStdString()); 

auto xTitleProps = xAxis->GetTitleProperties(); 
xTitleProps->SetFontSize(14); 
xTitleProps->SetFontFamilyToTimes(); 

auto xLabelProps = xAxis->GetLabelProperties(); 
xLabelProps->SetFontSize(14); 
xLabelProps->SetFontFamilyToTimes(); 

auto yAxis = chart->GetAxis(vtkAxis::LEFT); 
yAxis->SetTitle(QApplication::translate("DataSetChartWidget", "x(t), x*(t)").toStdString()); 

auto yTitleProps = yAxis->GetTitleProperties(); 
yTitleProps->SetFontSize(14); 
yTitleProps->SetFontFamilyToTimes(); 

auto yLabelProps = yAxis->GetLabelProperties(); 
yLabelProps->SetFontSize(14); 
yLabelProps->SetFontFamilyToTimes(); 

contextView->GetScene()->AddItem(chart.Get()); 

그리고 코드 :

auto realPlot = chart->AddPlot(vtkChart::LINE); 
realPlot->SetInputData(table.Get(), 0, 1); 

auto measuredPlot = chart->AddPlot(vtkChart::POINTS); 
measuredPlot->SetInputData(table.Get(), 0, 2); 

답변

1

당신은 축 제목의 수직 및 수평 정렬을 설정할 수 있습니다.

예컨대 귀하의 경우

myVtkChart->GetAxis(0)->GetTitleProperties()->SetJustificationToLeft(); 

xTitleProps->SetJustificationToRight(); 
yTitleProps->SetJustificationToLeft(); 

를 호출하기에 충분해야하지만 제목의 폭이 축 길이를 확장하지 않는 것 같다. 이것은 예상 결과를 얻기 위해 제목 문자열에 공백을 넣어야 할 필요가 있음을 의미합니다.

+0

이것은 작동하지 않습니다 ... – Anton

+0

죄송합니다, 질문에 대한 오해 ... 답변을 변경했습니다. – JohnnyQ

+0

죄송합니다,하지만 이것도 작동하지 않습니다 ... – Anton