I can remove axes using IsAxisVisible = false
like the answers here, but when I do so can no longer pan or zoom the graph.
Example code where the graph doesn't pan (using Oxyplot 2.0):
public class MainViewModel
{
public MainViewModel()
{
var tmp = new PlotModel { Title = "Simple example", Subtitle = "using OxyPlot" };
tmp.Axes.Add(new LinearAxis()
{
Position = AxisPosition.Bottom,
IsAxisVisible = false
});
tmp.Axes.Add(new LinearAxis()
{
Position = AxisPosition.Left,
IsAxisVisible = false
});
var series1 = new LineSeries { Title = "Series 1", MarkerType = MarkerType.Circle };
series1.Points.Add(new DataPoint(0, 0));
series1.Points.Add(new DataPoint(10, 18));
series1.Points.Add(new DataPoint(20, 12));
series1.Points.Add(new DataPoint(30, 8));
series1.Points.Add(new DataPoint(40, 15));
tmp.Series.Add(series1);
this.Model = tmp;
}
public PlotModel Model { get; private set; }
}
Edit:
xaml
<Window x:Class="SimpleDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
xmlns:simpleDemo="clr-namespace:SimpleDemo"
Title="OxyPlot SimpleDemo" Height="480" Width="640">
<Window.DataContext>
<simpleDemo:MainViewModel />
</Window.DataContext>
<Grid>
<oxy:PlotView Model="{Binding Model}" />
</Grid>
</Window>
xaml.cs
public partial class MainWindow
{
public MainWindow()
{
this.InitializeComponent();
}
}
The solution I've settled on (at least until the IsAxisVisible = false
issue described in the original question is fixed) is to implement Anu's answer, with the addition of:
Model.PlotMargins = new OxyThickness(0);
To hide the axis thickness.