如何绘制一条最适合最大值的线

发布于 2025-01-23 06:29:18 字数 283 浏览 2 评论 0原文

如何绘制最适合最大值的线性线线线(如红色下方的一个值)?我想找到每个x值的最大值。例如,当x为10时,最大y为2.5。当x为20时,最大y为4。然后,我想绘制这些点之间最佳拟合的线。

X和Y值来自表。

How do I draw a no linearline of best fit for the max values like the one in red below? I want to find the max y value for each x value. For example when x is 10 the max y is 2.5. When x is 20 the max y is 4. I then want to plot a line of best fit between these points.

The x and y values are coming from a table.

enter image description here

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

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

发布评论

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

评论(1

断肠人 2025-01-30 06:29:18

我不太明白这个问题(下次尝试提供更多信息),我认为您想要一条只有最大值的行,而忽略了所有其他信息。因此,为此,您可以在Python中列出与此相似(伪代码)的列表,

# assuming x values is a table with all the x coordinates on the graph
max_y = []
for i in x values:
  large_y = largest y value for that x value
  max_y.append(large_y)

然后我将使用Scipy使用插值。 scipy interpolation文档
我可能会选择使用RBF,但是有很多插值方法,您可以四处寻找最合适的方法。将表输入插值后,将为您提供一个与这些点匹配的方程式(或最佳拟合线,取决于您使用的方法)。然后,您可以绘制此方程式,这将是您最大值的最佳拟合行。

I don't quite understand the question (try to provide more information next time), I think you want a line that goes along just the max y values, and ignores all others. So to do this you could you could make a list in python similar to this (pseudocode)

# assuming x values is a table with all the x coordinates on the graph
max_y = []
for i in x values:
  large_y = largest y value for that x value
  max_y.append(large_y)

Then I would use interpolation using scipy. Scipy Interpolation Docs
I would probably choose to use RBF, but there are plenty of interpolation methods, you can look around for the one that is best fit. After inputting your tables into the interpolation, you will be given an equation that matches these points (or the line of best fit, depending what method you use). You can then graph this equation, and it will be your line of best fit for only the max y values.

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