Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

Is there an easy way in Python to get the coordinates from a plot?

is there a way to obtain specific coordinates from a plot even when they aren't used in the plotting process?

for example: can i extract the value at x=0.5 from the plot below? (just an easy example, want to use it for more complicated ones too)

import matplotlib.pyplot as plt
x=[0,1]
y=[1,2]
plt.plot(x,y)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No. This is not a limitation of Python. If your graph conforms precisely to a function, as in your example, you can obviously use the function to interpolate. If it does not, it wouldn't make sense to read intermediate data from your plot. For instance, you shouldn't try to read the y value for x = 4 from the graph below. In these cases, you need to resort to linear or non-linear curve fitting as suggested by the other responders.enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...