Skip to content

Reversed Y Axis + Non-Reversed Y Axis results in both being reversed #296

@PranishDutt

Description

@PranishDutt

XAML:

<OxyPlot:PlotView Model="{Binding Plot}"/>

Code:

    private void setupGraph()
    {
        // Plot Model
        Plot = new PlotModel { Title = "Reversed Axis + Non-Reversed Axis" };

        // Depth LineSeries
        LineSeries Y1Series = new LineSeries();
        Y1Series.Color = OxyColors.Blue;
        Plot.Series.Add(Y1Series);

        // Resistence LineSeries
        LineSeries Y2Series = new LineSeries();
        Y2Series.Color = OxyColors.Red;
        Plot.Series.Add(Y2Series);

        // Time Axis
        TimeSpanAxis timeAxis = new TimeSpanAxis { Position = AxisPosition.Bottom, Title = "Time", AxisTickToLabelDistance = 15, IsZoomEnabled = true, IsPanEnabled = true };
        Plot.Axes.Add(timeAxis);

        // Y1 Axis
        LinearAxis Y1AxisReversed = new LinearAxis { Position = AxisPosition.Left, Title = "Y1 (Reversed)", IntervalLength = 15, StartPosition = 1, EndPosition = 0, Minimum = -0.01, Maximum = 5, AxisTitleDistance = 15, AxisTickToLabelDistance = 15, AxislineColor = OxyColors.Blue, TextColor = OxyColors.Blue, TitleColor = OxyColors.Blue, MajorGridlineColor = OxyColors.DarkBlue, IsZoomEnabled = false, IsPanEnabled = false, MajorGridlineStyle = LineStyle.None };
        Plot.Axes.Add(Y1AxisReversed);

        // Y2 Axis
        LinearAxis Y2AxisNotReversed = new LinearAxis { Position = AxisPosition.Right, Title = "Y2 (Not Reversed)", IntervalLength = 15, StartPosition = 0, EndPosition = 1, Minimum = -0.01, AxisTitleDistance = 10, AxisTickToLabelDistance = 15, AxislineColor = OxyColors.Red, TextColor = OxyColors.Red, TitleColor = OxyColors.Red, MajorGridlineColor = OxyColors.DarkRed, IsZoomEnabled = false, IsPanEnabled = false, MajorGridlineStyle = LineStyle.None };
        Plot.Axes.Add(Y2AxisNotReversed);


        /* Test Data - Should be reversed*/
        timeAxis.Zoom(0, 30);
        Y1Series.Points.Add(new DataPoint(0, 0));
        Y1Series.Points.Add(new DataPoint(1, .1));
        Y1Series.Points.Add(new DataPoint(2, .2));
        Y1Series.Points.Add(new DataPoint(3, .3));
        Y1Series.Points.Add(new DataPoint(4, .4));
        Y1Series.Points.Add(new DataPoint(5, .5));
        Y1Series.Points.Add(new DataPoint(6, .6));
        Y1Series.Points.Add(new DataPoint(7, .7));
        Y1Series.Points.Add(new DataPoint(8, .8));
        Y1Series.Points.Add(new DataPoint(9, .9));
        Y1Series.Points.Add(new DataPoint(10, 1));

        /* Test Data - Shouldn't be reversed */
        Y2Series.Points.Add(new DataPoint(0, 0));
        Y2Series.Points.Add(new DataPoint(1, 1));
        Y2Series.Points.Add(new DataPoint(2, 2));
        Y2Series.Points.Add(new DataPoint(3, 3));
        Y2Series.Points.Add(new DataPoint(4, 4));
        Y2Series.Points.Add(new DataPoint(5, 5));
        Y2Series.Points.Add(new DataPoint(6, 6));
        Y2Series.Points.Add(new DataPoint(7, 7));
        Y2Series.Points.Add(new DataPoint(8, 8));
        Y2Series.Points.Add(new DataPoint(9, 9));
        Y2Series.Points.Add(new DataPoint(10, 10));

        Plot.InvalidatePlot(false);


    }

Results in:

reversedaxes

But, the red line should not be reversed (StartPosition = 0, EndPosition = 1). It should be starting from the bottom left and ascending.

On the off chance that this is actually a "feature," what would a possible solution be to achieve reversing the blue lineseries and leaving the red lineseries alone?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions