oxyplot 中的中心轴
Center Axes in oxyplot
我想用 oxyplot 绘制如下图所示的图表,问题是我不知道如何在值 50 处绘制轴(带值)。
代码:
var model = new PlotModel { Title = "EllipseAnnotations" };
model.Axes.Add( new LinearAxis {
Position = AxisPosition.Bottom,
Minimum = 20,
Maximum = 80,
PositionAtZeroCrossing = true,
ExtraGridlines = new[] { 50.0 },
ExtraGridlineStyle = LineStyle.Dash
});
model.Axes.Add(new LinearAxis {
Position = AxisPosition.Left,
Minimum = 20,
Maximum = 80,
PositionAtZeroCrossing = true,
ExtraGridlines = new[] { 50.0 }
});
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 10, Height = 10, Fill = OxyColors.LightGray, Stroke = OxyColors.Black, StrokeThickness = 1 });
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 30, Height = 30, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 60, Height = 60, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });
//model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 20, Height = 20, Fill = OxyColors.Aqua, Stroke = OxyColors.Black, StrokeThickness = 2 });
//model.Annotations.Add(new EllipseAnnotation { X = 30, Y = 20, Width = 20, Height = 20, Fill = OxyColors.Red, Stroke = OxyColors.Black, StrokeThickness = 2 });
//model.Annotations.Add(new EllipseAnnotation { X = 25, Y = 30, Width = 20, Height = 20, Fill = OxyColors.Blue, Stroke = OxyColors.Black, StrokeThickness = 2 });
这是它的样子
不确定这是否是您想要的,但添加
model.Annotations.Add(new TextAnnotation
{
TextPosition = new DataPoint(50, 50),
Text = "50",
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Middle,
StrokeThickness = 0
});
您的设置代码将产生这个
我想用 oxyplot 绘制如下图所示的图表,问题是我不知道如何在值 50 处绘制轴(带值)。
代码:
var model = new PlotModel { Title = "EllipseAnnotations" };
model.Axes.Add( new LinearAxis {
Position = AxisPosition.Bottom,
Minimum = 20,
Maximum = 80,
PositionAtZeroCrossing = true,
ExtraGridlines = new[] { 50.0 },
ExtraGridlineStyle = LineStyle.Dash
});
model.Axes.Add(new LinearAxis {
Position = AxisPosition.Left,
Minimum = 20,
Maximum = 80,
PositionAtZeroCrossing = true,
ExtraGridlines = new[] { 50.0 }
});
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 10, Height = 10, Fill = OxyColors.LightGray, Stroke = OxyColors.Black, StrokeThickness = 1 });
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 30, Height = 30, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 60, Height = 60, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });
//model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 20, Height = 20, Fill = OxyColors.Aqua, Stroke = OxyColors.Black, StrokeThickness = 2 });
//model.Annotations.Add(new EllipseAnnotation { X = 30, Y = 20, Width = 20, Height = 20, Fill = OxyColors.Red, Stroke = OxyColors.Black, StrokeThickness = 2 });
//model.Annotations.Add(new EllipseAnnotation { X = 25, Y = 30, Width = 20, Height = 20, Fill = OxyColors.Blue, Stroke = OxyColors.Black, StrokeThickness = 2 });
这是它的样子
不确定这是否是您想要的,但添加
model.Annotations.Add(new TextAnnotation
{
TextPosition = new DataPoint(50, 50),
Text = "50",
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Middle,
StrokeThickness = 0
});
您的设置代码将产生这个