Search code examples
c#wpfoxyplotlineseries

OxyPlot - How to remove Axes


I would like to create an Oxyplot view without any axes visible.

Could anyone tell me how to do so?

To avoid missunderstandings, I never added any axes to the plotmodel.

This code adds axes already. How to avoid that they are shown?

C#

        plot = new PlotModel();
        var ser = new LineSeries();
        ser.Points.Add(new DataPoint(1, 1));
        plot.Series.Add(ser);

XAML

<oxy:PlotView Background="Transparent" Model="{Binding plot}"</oxy:PlotView>

enter image description here


Solution

  • As stated in in oxyplot axes documentation:

    If no axes are defined, linear axes will be added to the bottom and left.

    So, as @JohnStrit said, you have to add "invisible" axis to your plot model, like that:

    plot.Axes.Add(new LinearAxis()
    {
        Position = AxisPosition.Bottom,
        IsAxisVisible = false
    });
    
    plot.Axes.Add(new LinearAxis()
    {
        Position = AxisPosition.Left,
        IsAxisVisible = false
    });
    

    I've checked out this way and it works.