用 C# 绘图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/550371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 07:48:25  来源:igfitidea点击:

Plotting with C#

c#plotscientific-computing

提问by

C# seems to show some promise for scientific computing, but I found very little about one plotting 2D graphs, which is very important both for science student and scientists.

C# 似乎显示出对科学计算的一些希望,但我发现很少有关于绘制 2D 图的东西,这对理科学生和科学家都非常重要。

Is there a reliable, free, way to create publication quality 2D plot with C# ? And the capacity to save to several formats (png, eps, ...). Something similar to Python's matplotlib ?

是否有一种可靠、免费的方法可以使用 C# 创建发布质量的 2D 绘图?并且能够保存为多种格式(png、eps、...)。类似于 Python 的 matplotlib 的东西?

回答by BBetances

I started using the new ASP.NET Chart control a few days ago, and it's absolutely amazing in its capabilities.

几天前我开始使用新的 ASP.NET Chart 控件,它的功能绝对令人惊叹。

Here is the link.

链接在这里。

EDIT: This is obviously only if you are using ASP.NET. Not sure about WinForms.

编辑:这显然只有在您使用 ASP.NET 时才适用。不确定 WinForms。

回答by BobbyShaftoe

NPlot is a pretty good simple open source 2D plotting API. Unfortunately, the web site is down. I don't know if this is just temporary or not. I haven't heard of any bad news. It may come back up.

Nplot 是一个相当不错的简单开源 2D 绘图 API。不幸的是,该网站已关闭。我不知道这是否只是暂时的。我没有听到任何坏消息。它可能会回来。

http://www.nplot.com

http://www.nplot.com

Here is an article describing it:

这是一篇描述它的文章:

http://aspnet.4guysfromrolla.com/articles/072507-1.aspx

http://aspnet.4guysfromrolla.com/articles/072507-1.aspx

The previous article uses VB.NET, but obviously this will work with C#.

上一篇文章使用了 VB.NET,但显然这将适用于 C#。

Again, not sure why nplot's site is not currently working but it is a somewhat popular plotting API that I've used in the past. I post it for your information and in case of the likely event nplot will be back up soon. :)

同样,不确定为什么 nplot 的站点当前无法运行,但它是我过去使用过的一种有点流行的绘图 API。我发布它以供您参考,如果发生可能的事件,nplot 将很快备份。:)

Edit:

编辑:

Thanks to a Hosam Aly, it looks like the SourceForge project can still be accessed here:

感谢 Hosam Aly,看起来 SourceForge 项目仍然可以在这里访问:

http://sourceforge.net/projects/nplot

http://sourceforge.net/projects/nplot

回答by Bob Nadler

ZedGraphis a good choice.

ZedGraph是一个不错的选择。

回答by gimel

See Samples Environment for Microsoft Chart Controls:

请参阅Microsoft Chart Controls 的示例环境

The samples environment for Microsoft Chart Controls for .NET Framework contains over 200 samples for both ASP.NET and Windows Forms. The samples cover every major feature in Chart Controls for .NET Framework. They enable you to see the Chart controls in action as well as use the code as templates for your own web and windows applications.

Microsoft Chart Controls for .NET Framework 的示例环境包含 200 多个ASP.NET 和 Windows 窗体示例。这些示例涵盖了 .NET Framework 图表控件中的每个主要功能。它们使您能够查看运行中的 Chart 控件,并将代码用作您自己的 Web 和 Windows 应用程序的模板。

Seems to be more business oriented, but may be of some value to science students and scientists.

似乎更面向商业,但可能对理科学生和科学家有一定的价值。

回答by Jon Harrop

FWIW, you probably want to look at F#instead of C# in the context of technical computing because F#is specifically designed for that purpose. However, I developed my own commercial plotting library because I was not satisfied with anything freely available on .NET.

FWIW,您可能希望在技术计算的上下文中查看F#而不是 C#,因为F#是专门为此目的而设计的。但是,我开发了自己的商业绘图库,因为我对 .NET 上免费提供的任何内容都不满意。

回答by Danvil

gnuplotis an actively maintained program widely used in the scientific community. Normally plots are generated from data files which you can write out in your C# program, but it is also possible to call the gnuplot executable from C# and display the generated image in a C# picture box.

gnuplot是一个在科学界广泛使用的积极维护的程序。通常绘图是从数据文件生成的,您可以在 C# 程序中写出这些数据文件,但也可以从 C# 调用 gnuplot 可执行文件并在 C# 图片框中显示生成的图像。

回答by MajesticRa

There is OxyPlotwhich I recommend. It has packages for WPF, Metro, Silverlight, Windows Forms, Avalonia UI, XWT. Besides graphics it can export to SVG, PDF, Open XML, etc. And it even supports Mono and Xamarin for Android and iOS. It is actively developed too.

OxyPlot我建议。它有 WPF、Metro、Silverlight、Windows Forms、Avalonia UI、XWT 的包。除了图形,它还可以导出为 SVG、PDF、Open XML 等。它甚至支持 Android 和 iOS 的 Mono 和 Xamarin。它也被积极开发。

There is also a new (at least for me) open source .NET plotting library called Live-Charts. The plots are pretty interactive. Library suports WPF, WinForms and UWP. Xamarin is planned. The design is made towards MV* patterns. But @Pawe? Audionysos suggests not such a good performance of Live-Charts WPF.

还有一个新的(至少对我而言)开源 .NET 绘图库,称为Live-Charts。这些情节非常具有互动性。库支持 WPF、WinForms 和 UWP。Xamarin 已计划。该设计是针对 MV* 图案进行的。但是@Pawe?Audionysos 认为 Live-Charts WPF 的性能不是很好。

回答by CodyF

I just wanted to supplement MajesticRa's recommendation of OxyPlot, and point out how OxyPlot can be used for a variety of plotting cases. The software is free and Open-Source, very polished, and allows for a variety of uses beyon normal 2D mapping.

我只是想补充 MajesticRa 对OxyPlot的推荐,并指出 OxyPlot 如何用于各种绘图案例。该软件是免费和开源的,非常精美,并允许在普通 2D 映射之外的各种用途。

I've been using OxyPlot for an unorthodox project, where I display (in WPF/C#) a map (Robotic Occupancy Grid) which I could overlay with LineSeries (Path Traveled) and PointSeries (Way Points). Using the OxyPlot ImageAnnotation feature I am able to display 60Hz Video within my OxyPlot, by periodically updating the ImageAnnotation on its own thread, while mapping Series of points overtop the video. The background video and points are even scalable and translatable.

我一直在使用 OxyPlot 进行一个非正统的项目,在那里我显示(在 WPF/C# 中)一个地图(机器人占用网格),我可以用 LineSeries(路径旅行)和 PointSeries(航路点)覆盖它。使用 OxyPlot ImageAnnotation 功能,我可以在我的 OxyPlot 中显示 60Hz 的视频,方法是在自己的线程上定期更新 ImageAnnotation,同时将一系列点映射到视频之上。背景视频和点甚至是可扩展和可翻译的。

Hopefully this is helpful for other looking to display plots overtop of images and videos.

希望这对其他希望在图像和视频上显示绘图的人有所帮助。