I am coding an app in Python that collects informations about temperature and timing and plot them in a graph.
As seen here Smooth line with spline + datetime objects doesn't work
I want to interpolate the few temperature values to make smoother the graph temp-time.
This function retrieves the values of temperature and time and puts them into array related to the position (Bedroom and Kitchen):
xTemp, yTemp = dataList[1].split(',')
xTime, yTime = dataList[3].split(',')
t = datetime.fromtimestamp(float(xTime)).strftime('%Y-%m-%d %H:%M:%S') # get time string
st = datetime.strptime(t, '%Y-%m-%d %H:%M:%S') # get datetime from time string
x.append(st)
y.append(xTemp)
X = np.array(x)
Y = np.array(y)
Xnew = matplotlib.dates.date2num(X)
if(len(X) >= 5):
X_smooth = np.linspace(Xnew.min(), Xnew.max(), 10)
Y_smooth = interp1d(X, Y, X_smooth)
# , assume_sorted = True, kind = 'quadratic')
a.plot(X_smooth, Y_smooth)
I have got this error:
NotImplementedError: [736817.73790509 736817.73791152 736817.73791795 736817.73792438
736817.73793081 736817.73793724 736817.73794367 736817.7379501
736817.73795653 736817.73796296] is unsupported: Use fitpack routines for other types.
Can you help me? Thanks
X
,Y
, andX_smooth
(wiht a debugger or just printing them) and replace the code above, with these values. – betontalpfa