首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在WindowsForms中使用OxyPlot

在WindowsForms中使用OxyPlot
EN

Stack Overflow用户
提问于 2015-06-19 03:25:14
回答 1查看 2.8K关注 0票数 1

到目前为止,从我在OxyPlot文档中看到的情况来看,并没有太多的东西。如何使用OxyPlot获取x-y点并将其绘制成图形?

以下是我的两点尝试,并将它们绘制成图表:

代码语言:javascript
运行
复制
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文档,它充其量是非常广泛的)。

EN

回答 1

Stack Overflow用户

发布于 2015-06-19 05:19:02

我知道您提到过WinForms,但是您必须能够轻松地查看所有的示例和源代码,而不管使用的是哪种UI框架。在你最喜欢的搜索引擎中查找oxyplot,你会在他们的GitHub页面上找到大量的例子(或者任何他们在查看这个答案时都会使用的repo服务)。

无论如何,您需要的是一个ScattierSeries图。然后,您可以向其添加点。举个例子:

代码语言:javascript
运行
复制
    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非常灵活,在我最近的项目中,我已经能够很容易地扩展它。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30924062

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档