到目前为止,从我在OxyPlot
文档中看到的情况来看,并没有太多的东西。如何使用OxyPlot获取x-y点并将其绘制成图形?
以下是我的两点尝试,并将它们绘制成图表:
var dataModel = new PlotModel { Title = "data plot" };
foreach (var pt in dataProfile)
{
XYData.Text = String.Format("X:{0} Y:{1}", pt.X,pt.Y);
dataModel.Series.Add(pt.X, pt.Y); //(obviously wrong here)
this.plot1.Model = dataModel;
}
我需要更改/添加什么:dataModel.Series.Add(pt.X, pt.Y);
,这样它才能添加点?此外,如何绘制随时间变化的点?(x-y,随着时间t的流逝而绘制)
有没有人知道一个好的OxyPlot教程站点(针对WinForms),因为我找不到(除了OxyPlot文档,它充其量是非常广泛的)。
发布于 2015-06-19 05:19:02
我知道您提到过WinForms
,但是您必须能够轻松地查看所有的示例和源代码,而不管使用的是哪种UI框架。在你最喜欢的搜索引擎中查找oxyplot,你会在他们的GitHub页面上找到大量的例子(或者任何他们在查看这个答案时都会使用的repo服务)。
无论如何,您需要的是一个ScattierSeries
图。然后,您可以向其添加点。举个例子:
public static PlotModel ExampleScatterSeriesPlot()
{
var plotModel1 = new PlotModel();
plotModel1.Subtitle = "The scatter points are added to the Points collection.";
plotModel1.Title = "ScatterSeries";
var linearAxis1 = new LinearAxis();
linearAxis1.Position = AxisPosition.Bottom;
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
plotModel1.Axes.Add(linearAxis2);
var scatterSeries1 = new ScatterSeries();
scatterSeries1.Points.Add(new ScatterPoint(0.667469348137951, 0.701595088793707));
scatterSeries1.Points.Add(new ScatterPoint(7.74765135149828, 5.11139268759237));
scatterSeries1.Points.Add(new ScatterPoint(7.97490558492714, 8.27308291023275));
scatterSeries1.Points.Add(new ScatterPoint(1.65958795308116, 7.36130623489679));
scatterSeries1.Points.Add(new ScatterPoint(2.6021636475819, 5.06004851081411));
scatterSeries1.Points.Add(new ScatterPoint(2.30273722312541, 3.87140443263175));
scatterSeries1.Points.Add(new ScatterPoint(2.15980615101746, 0.208108848989061));
scatterSeries1.ActualPoints.Add(new ScatterPoint(0.667469348137951, 0.701595088793707));
scatterSeries1.ActualPoints.Add(new ScatterPoint(7.74765135149828, 5.11139268759237));
scatterSeries1.ActualPoints.Add(new ScatterPoint(7.97490558492714, 8.27308291023275));
scatterSeries1.ActualPoints.Add(new ScatterPoint(1.65958795308116, 7.36130623489679));
scatterSeries1.ActualPoints.Add(new ScatterPoint(2.6021636475819, 5.06004851081411));
scatterSeries1.ActualPoints.Add(new ScatterPoint(2.30273722312541, 3.87140443263175));
scatterSeries1.ActualPoints.Add(new ScatterPoint(2.15980615101746, 0.208108848989061));
plotModel1.Series.Add(scatterSeries1);
return plotModel1;
}
在我给您的示例浏览器链接下有一大堆示例。上面的代码是从那里截取的。所以,研究一下所有可用的选项。OxyPlot非常灵活,在我最近的项目中,我已经能够很容易地扩展它。
https://stackoverflow.com/questions/30924062
复制相似问题