matplotlib - How can I fit my plots from measured data? -


How can I fit my plots?

So far, I got the following code, which plots a variety of graphs of an array (data from one experiment) because it is placed in a loop:

  import matplotlib plt plt.figure (6) .title ("APD" + str (detector) + "_Correlations_log_graph") plt.savefig (datafler + "/ apd" + arr (detector) + "_Correlations_log_graph.png")   

Works with a logarithmic plot so far, but I am thinking that Iting process can work properly. Finally I have a formula or / and a graph that best describes the data I measured.

If anyone can help me then I will be happy!

You can use curve_fit from scipy.optimize

  # - * - Coding: UTF-8 - * - Import as NP import. Import scrip_ptmit from multiplybipop plot curve_fit def func (x, a): return np.exp (a * x) x, y, z = np.loadtxt ("fit3.dat", unpac = tru) pop, pcov = Curve_fit (func, x, y) y_fit = np.exp (popt [0]] * x) plt.plot (x, y, 'o') plt.errorbar (x, y, yerr = z) plt.plot ( X, y_fit) plt.savefig ("fit3_plot.png") plt.show ()   

In your case, you can define func accordingly. popt is an array that has the value of your fitting parameter.

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -