i want to plot this function ( y = a * ln(x) + b ) in python. This is my Code:
def func(x, a, b):
return a * np.log(x) + b
popt, _ = curve_fit(func, x, y)
a, b = popt
x_line = arrange(min(x), max(x), 1)
y_line = func(x_line, a, b)
plt.plot(x_line, y_line)
plt.show()
My "x" contains this
array([[1790],
[1800],
[1810],
[1820],
[1830],
[1840],
[1850],
[1860],
[1870],
[1880],
[1900],
[1910],
[1920],
[1930],
[1940],
[1950],
[1960],
[1970],
[1980],
[1990],
[2000],
[2010]], dtype=int64)
and my "y" this
array([[ 3.929214],
[ 5.308483],
[ 7.239881],
[ 9.638453],
[ 12.86602 ],
[ 17.069453],
[ 23.191876],
[ 31.443321],
[ 39.818449],
[ 50.189209],
[ 76.212168],
[ 92.228496],
[106.021537],
[123.202624],
[132.164569],
[151.325798],
[179.323175],
[203.302031],
[226.542199],
[248.718302],
[281.424603],
[308.745538]])
But when i rund the code i always get this error:
object too deep for desired array
I hope someone can help me because i spend to much time on this.