winform中OxyPlot的X轴文本45°显示
时间: 2023-05-26 08:05:40 浏览: 104
要在WinForm中将OxyPlot的X轴文本旋转45度显示,您可以使用下面的代码片段:
```c#
var plotModel = new PlotModel { Title = "My Plot" };
var linearAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "X Axis" };
var categoryAxis = new CategoryAxis { Position = AxisPosition.Left, Title = "Y Axis", Angle = 45 };
categoryAxis.ActualLabels.Add("Label 1");
categoryAxis.ActualLabels.Add("Label 2");
categoryAxis.ActualLabels.Add("Label 3");
plotModel.Axes.Add(linearAxis);
plotModel.Axes.Add(categoryAxis);
var series = new LineSeries { Title = "My Series" };
series.Points.Add(new DataPoint(1, 1));
series.Points.Add(new DataPoint(2, 3));
series.Points.Add(new DataPoint(3, 2));
plotModel.Series.Add(series);
var plotView = new OxyPlot.WindowsForms.PlotView();
plotView.Model = plotModel;
this.Controls.Add(plotView);
```
在上面的代码中,通过设置Angle属性为45实现了将X轴文本旋转45度显示的效果。
阅读全文