Search code examples
wpfoxyplot

Set the Y position of the X axis in OxyPlot


I am plotting a basic LineSeries with the excellent OxyPlot library :

enter image description here I can't find how to set the X axis to be centered at the 0 Y value and not at the bottom of the PlotArea.

My code-behind is as follow :

Model = new PlotModel();
LineSeries RightingLever = new LineSeries();
RightingLever.Title = "Righting Lever";
// adding points
Model.Series.Add(RightingLever);
PlotView.Model = Model;

Solution

  • I was looking for the PositionAtZeroCrossing property of the Axis class.

    foreach (var axis in Model.Axes)
    {
        axis.PositionAtZeroCrossing = true;
        axis.AxislineStyle = LineStyle.Automatic;
    }
    

    enter image description here