I have this code, the txt data is not important. the thing that puzzles me is why does it work with the *popt in plt.plot. but it doesnt when I take that symbol out
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize as sc
fecha, temperatura = np.loadtxt('munich_temperatures_average_with_bad_data.txt', unpack=True)
keep = np.abs(temperatura) < 90
fecha = fecha[keep]
temperatura = temperatura[keep]
def cosine(x, a, b, c):
return a * np.cos(2 * np.pi * x + b) + c
popt, pcov = sc.curve_fit(cosine, fecha, temperatura)
plt.plot(fecha, temperatura, '.')
xfine = np.linspace(1995, 2014, 100)
plt.plot(xfine, cosine(xfine, *popt), color='red', lw=2)
the error TypeError: cosine() missing 2 required positional arguments: 'b' and 'c' appears when * is not on the plt.plot