title: Linear fit with scipy.optimize.curve_fit
body: <p>I just started programming last week, so please be gentle ;)</p>
  
  <p>What I try to do is a linear fit with curve_fit to determine the two contributions to the slope. I tried:</p>
  
  <pre><code>import os
  from os import listdir
  from os.path import isfile, join
  from scipy.optimize import curve_fit
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.axes as ax 
  from scipy import asarray as ar,exp
  
  freq_lw_tuple = [('10.0', 61.32542701946727), ('10.5', 39.367147015318501), ('11.0', 58.432147581817077), ('11.5', 68.819336676144317), ('12.0', 71.372078906193025), ('12.5', 73.113662907539336), ('13.0', 75.855316075062603), ('13.5', 76.798724771266322), ('14.0', 79.065657225891329), ('14.5', 81.637345805693897), ('15.0', 82.407248034320034)]
  def func_lw(x_lw,alpha,g):
      return (alpha/g)*x_lw
  
  #define constants
  m_e = 9.109383*(10**(-31)) #mass of electron in [kg]
  q_e = 1.602176*(10**(-19)) #value of electron charge
  pi = 3.14159               #pi
  #unzip the list of tuples
  unzipped = list(zip(*freq_lw_tuple))
  
  xval_list = []
  yval_list = []
  for k in range(0,len(unzipped[0])):
      x_value = (8/np.sqrt(3))*((2*pi*m_e*float(unzipped[0][k])*10**9)/q_e)   #calculate x values
      xval_list.append(x_value)
      y_value = unzipped[1][k]*10**(-4)*4*pi*10**(-7)    #transform unit of y values
      yval_list.append(y_value)
  
  
  start_params2 = [0.01,2]
  fitted_params, pcov = curve_fit(func_lw, xval_list, yval_list, start_params2)
  </code></pre>
  
  <p>And it actually gives some results, but when I want to</p>
  
  <pre><code>print(func_lw(xval_list,*fitted_params))
  </code></pre>
  
  <p>I just get an empty list and probably that is the reason why I can't </p>
  
  <pre><code>plt.plot(xval_list, func_lw(xval_list, *fitted_params))
  </code></pre>
  
  <p>(This gives an error like: x and y must have same first dimensions)</p>
  
  <p>[Edit: added some data for freq_lw_tuple and imports]</p>