Winforms / GDI+ 绘制图表的曲线

发布于 2024-07-18 03:27:42 字数 143 浏览 8 评论 0原文

在我的 Winforms 应用程序中,我有一个小图表。 没什么特别的,只是用线连接一堆 x/y 点。

最好画一条曲线而不是直线来连接这些点。 但由于数学从来都不是我的强项,我不知道该怎么做。

任何类型的样本或建议都会有帮助。

In my Winforms application I have a small chart. Nothing fancy just a bunch of x/y points I connect with lines.

It would be nice to draw a curve instead of a lines to connect these points. But since mathematics was never my strong side I have no idea how to do that.

Any kind of sample or advice would be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

这非常简单 - 不需要任何数学 - 只需使用 Graphics.DrawCurve 而不是 DrawPolygon/DrawLine (请参阅有关此功能的非常好的帮助)。

This is very simple - no need for any math - just use Graphics.DrawCurve instead of DrawPolygon/DrawLine (see the very good help on this function).

情绪操控生活 2024-07-25 03:27:42

对于线程复活表示歉意,但我必须回复这个:

在你的脑海中清楚你想要实现什么。我不知道你的项目的细节,但建议的方法是不适合许多应用。 正确的解决方案取决于您是否想让所绘制的曲线看起来漂亮,或者表示有意义的数据。 对于前者,绘制贝塞尔曲线很好,但它们在数学上没有意义,如果您试图绘制一个以科学严谨的方式解释的图表,它们会误导用户。 对于许多应用,您需要的是最适合的生产线。 它们具有明确的函数形式,例如 2 次多项式(也称为抛物线)、对数曲线或移动平均值。 所有这些都存在于 Excel 中,并且都有特定的应用程序,对于其特定职权范围之外的任何内容来说,显然都是错误的选择。 数据统计分析的主题可能超出了 StackOverflow 帖子的范围 - 但首先,查找“线性回归”,您所描述的内容已由该数学领域全面处理。

Apologies for the thread resurrection, but I had to reply to this one:

Be clear in your mind what you want to achieve. I don't know the details of your project, but the methods being suggested are not appropriate for many applications. The correct solution depends on whether you intend the curves you're drawing to simply look nice, or to represent meaningful data. For the former, drawing a bezier curve is fine, but they are not mathematically meaningful and if you're trying to draw a graph to be interpreted with scientific rigour, they will mislead the user. For many applications what you'd want is a best-fit line. These have clear functional form, for example, a degree-2 polynomial (otherwise known as a parabola), a logarithmic curve, or a moving-average. All these are present in Excel and all have specific applications and are emphatically the wrong choice for anything outside their specific remit. The topic of statistical analysis of data is probably beyond the scope of a StackOverflow post - but to start with, look up 'linear regression', what you're describing is comprehensively dealt with by this area of mathematics.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文