从 python plot (matplotlib) 中找到相应 x 的 y 值 [英] Find y value for respective x from python plot (matplotlib)

查看:34
本文介绍了从 python plot (matplotlib) 中找到相应 x 的 y 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用绘制的折线图来查找代码以将 'y' 的值与相应的 'x' 值相匹配.我已经使用matplotlib.pyplot绘制图形.我想要其"y"值的"x"值不是x值数组的一部分.有没有办法找到相同的"y"值?

I'm trying to find the code to find the value of 'y' to a respective 'x' value by using a plotted line graph. I've used matplotlib.pyplot to plot a graph. The 'x' value for which I want the 'y' value is not a part of the x values array. Is there a way to find the respective 'y' value for the same?

如果必须找到X等于0.75的Y值,该怎么做?

If I have to find the value of Y for X = 0.75, how do I do that?

推荐答案

我们可以使用numpy库中的interp函数.

We can use the interp function from numpy library.

import numpy as np
x = [0.01474926, 0.96923077, 1]
y = [1, 0.7875, 0]
np.interp(0.75, x,y)
0.8363082148652623

这篇关于从 python plot (matplotlib) 中找到相应 x 的 y 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆