matplotlib - Is there a python equivalent for "Screen Reader" in Origin Software? -
i plotting 2 graphs on same curve. code goes :
x = np.array([86,14,19,24,30,55,41,46]) y1 = np.array([96,86,82,78,80,101,161,32]) y2 = np.array([54,54,48,54,57,76,81,12]) y4 = np.concatenate([y2.reshape(8,1),y1.reshape(8,1)],1) plot(x,y4)
i need values @ points other in x
array. example: values 30,50 , 78.
there option read data graph in origin using "screen reader" (i.e. when point in graph, value.).
is there equivalent in python?
.plot matplotlib.plot
here's simple method, i'm going highlight limitations. it's great since requires no complex analysis, if data sparse, or deviates linear behavior, it's poor approximation.
>>> import matplotlib.pyplot plt >>> plt.figure() <matplotlib.figure.figure object @ 0x7f643a794610> >>> import numpy np >>> bins = np.array(range(10)) >>> quad = bins**2 >>> lin = 7*bins-12 >>> plt.plot(bins, quad, color="blue") [<matplotlib.lines.line2d object @ 0x7f643298e710>] >>> plt.plot(bins, lin, color="red") [<matplotlib.lines.line2d object @ 0x7f64421f2310>] >>> plt.show()
here show plot quadratic function [f(x) = x^2] , linear fit between points @ (3,9) , (4,16).
i can approximate getting slope:
m = (y2-y1)/(x2-x1) = (16-9)/(4-3) = 7
i can find linear function value @ point, i'll (3,3):
f(x) = 7x + b 9 = 7(3) + b b = -12 f(x) = 7x - 12
and can approximate value between 3 , 4.
the error become unusable quickly, however, within close data points, it's quite accurate. example:
# quadratic f(3.5) = 3.5**2 = 12.25 # linear f(3.5) = 7*3.5 - 12 = 12.5
since error (experimental-theoretical)/(theoretical), (12.25-12.5)/(12.5), or error of -2% (not bad).
however, if try f(50), get.
# quadratic f(50) = 2500 # linear f(50) = 7*50 - 12 = 338
or error of 639%.
Comments
Post a Comment