How to display right axis when using vtkChartXY?

Hello everyone. I was wondering how to display right axis of the 2D chart. After test, I found the code like this does not work, left axis still show, and right axis does not appear. code snippet:

    auto chart = vtkSmartPointer<vtkChartXY>::New();
    chart->GetAxis(vtkAxis::LEFT)->SetVisible(false);
    chart->GetAxis(vtkAxis::RIGHT)->SetVisible(true);

VTK version: 9.2.0
OS: Windows 11

Hey, this is a bit different than you’re used to. The way to get the extra axes to show up and use them for plots is to set something called a plot corner. Add your plots to the chart as usual and then call

chart->SetPlotCorner(plot, 1);

The default plot corner is 0, which uses the left and bottom axes. 1 uses bottom and right; 2 uses right and top and 3 uses top and left. I feel like this should have enum types.

1 Like

Thanks! Now, it works.