ewinform中OxyPlot的X轴文本45°显示
时间: 2023-05-26 10:05:31 浏览: 168
可以通过设置Axis.TitleOrientation和Axis.LabelAngle属性来实现。
示例代码:
```csharp
var xaxis = new CategoryAxis
{
Position = AxisPosition.Bottom,
ItemsSource = new List<string> { "A", "B", "C", "D", "E", "F", "G" },
Title = "X Axis Title",
TitleOrientation = 45, // 设置标题倾斜角度
LabelAngle = 45 // 设置标签倾斜角度
};
var yaxis = new LinearAxis
{
Position = AxisPosition.Left,
Title = "Y Axis Title"
};
var plotModel = new PlotModel
{
Title = "Example Plot",
Axes = { xaxis, yaxis }
};
var series = new LineSeries
{
MarkerType = MarkerType.Circle,
MarkerSize = 4,
MarkerStroke = OxyColors.White,
MarkerFill = OxyColors.Green,
Color = OxyColors.SkyBlue,
ItemsSource = new List<DataPoint>
{
new DataPoint(0, 0),
new DataPoint(1, 5),
new DataPoint(2, 7),
new DataPoint(3, 2),
new DataPoint(4, 4),
new DataPoint(5, 6),
new DataPoint(6, 9)
}
};
plotModel.Series.Add(series);
var plotView = new PlotView
{
Model = plotModel
};
this.Content = plotView;
```
结果:
![image](https://user-images.githubusercontent.com/77518322/137235535-1e8e057f-6d9d-4981-b6de-8c72b141ff55.png)
阅读全文