我想绘制一个与下图完全相同的情节图。
这里的问题是网格线。我不想把它们画在最大的圆圈之外。
这就是我现在所能得到的:
PS:对于其他想知道如何实现这一目标的人:(特别感谢@dd4711帮助我this question
var model = new PlotModel {
Title = "EllipseAnnotations",
PlotAreaBorderColor = OxyColors.Transparent
};
var series = new LineSeries {
MarkerType = MarkerType.Cross,
MarkerSize = 7,
MarkerStroke = OxyColors.Red,
MarkerStrokeThickness = 3,
Color = OxyColors.Red
};
series.Points.Add(new DataPoint(65, 45));
model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 10, Height = 10, Fill = OxyColor.FromAColor(0xaa,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,
});
for (int x = 2; x < 9; x++)
{
if (x != 5)
{
model.Annotations.Add(new TextAnnotation
{
TextPosition = new DataPoint(x * 10, 50),
Text = (x * 10).ToString(),
Stroke = OxyColors.White,
Background = OxyColors.White,
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Middle,
StrokeThickness = 0
});
model.Annotations.Add(new TextAnnotation
{
TextPosition = new DataPoint(50, x*10),
Text = (x * 10).ToString(),
Stroke = OxyColors.White,
Background = OxyColors.White,
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Middle,
StrokeThickness = 0
});
}
}
model.Annotations.Add(new TextAnnotation
{
TextPosition = new DataPoint(50, 50),
Text = "50",
Stroke = OxyColor.FromRgb(0xdd, 0xdd, 0xdd),
Background = OxyColor.FromRgb(0xdd, 0xdd, 0xdd),
TextHorizontalAlignment = HorizontalAlignment.Center,
TextVerticalAlignment = VerticalAlignment.Middle,
StrokeThickness = 0
});
model.Axes.Add(new LinearAxis
{
Position = AxisPosition.Bottom,
Minimum = 15,
Maximum = 85,
MajorStep = 10,
MajorGridlineStyle = LineStyle.Dot,
ExtraGridlines = new[] { 50.0 },
ExtraGridlineColor = OxyColors.Black,
AxislineColor = OxyColors.Transparent,
TextColor = OxyColors.Transparent,
TicklineColor = OxyColors.Transparent
});
model.Axes.Add(new LinearAxis
{
Position = AxisPosition.Left,
Minimum = 15,
Maximum = 85,
MajorStep = 10,
MajorGridlineStyle = LineStyle.Automatic,
ExtraGridlines = new[] { 50.0 },
ExtraGridlineColor = OxyColors.Black,
AxislineColor =OxyColors.Transparent,
TextColor = OxyColors.Transparent,
TicklineColor = OxyColors.Transparent
});
model.Series.Add(series);