gpt4 book ai didi

c# - Oxyplot 中具有共享轴的多个图

转载 作者:行者123 更新时间:2023-11-30 15:30:27 25 4
gpt4 key购买 nike

我想使用 OXYPLOT 库添加多个具有共享 x 轴的绘图。示例代码如下,设置了4个不同的y轴共享同一个x轴。但是我只能在第一个 x&y 轴上绘制数据,而不能在其他轴上绘制数据。任何类型的建议将不胜感激。

    [Example("Untitled")]
public static PlotModel Untitled()
{
var plotModel1 = new PlotModel();
plotModel1.PlotMargins = new OxyThickness(40,20,40,30);
var linearAxis1 = new LinearAxis();
linearAxis1.EndPosition = 0.25;
linearAxis1.Maximum = 1;
linearAxis1.Minimum = -1;
linearAxis1.Title = "C1";
linearAxis1.Key= "C1";
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
linearAxis2.EndPosition = 0.5;
linearAxis2.Maximum = 1;
linearAxis2.Minimum = -1;
linearAxis2.Position = AxisPosition.Right;
linearAxis2.StartPosition = 0.25;
linearAxis2.Title = "C2";
linearAxis2.Key= "C2";
plotModel1.Axes.Add(linearAxis2);
var linearAxis3 = new LinearAxis();
linearAxis3.EndPosition = 0.75;
linearAxis3.Maximum = 1;
linearAxis3.Minimum = -1;
linearAxis3.StartPosition = 0.5;
linearAxis3.Title = "C3";
linearAxis3.Key= "C3";
plotModel1.Axes.Add(linearAxis3);
var linearAxis4 = new LinearAxis();
linearAxis4.Maximum = 1;
linearAxis4.Minimum = -1;
linearAxis4.Position = AxisPosition.Right;
linearAxis4.StartPosition = 0.75;
linearAxis4.Title = "C4";
linearAxis1.Key= "C4";
plotModel1.Axes.Add(linearAxis4);
var linearAxis5 = new LinearAxis();
linearAxis5.Maximum = 100;
linearAxis5.Minimum = 0;
linearAxis5.Position = AxisPosition.Bottom;
linearAxis5.Title = "s";
linearAxis5.Key= "s";
plotModel1.Axes.Add(linearAxis5);
return plotModel1;
}

最佳答案

将 XAxisKey 和 YAxisKey 属性分配给您的系列。

PlotModel pm = new PlotModel();

OxyPlot.Series.FunctionSeries s1 = new FunctionSeries(Math.Sin, -10, 10, 0.1, "sin(x)");
s1.YAxisKey = "axesY2";
s1.XAxisKey = "axesX2";
pm.Series.Add(s1);

在您的例子中, key 是“C1”、“C2”和“C3”等。

关于c# - Oxyplot 中具有共享轴的多个图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22152733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com