[Matplotlib-users] TypeError: float() argument must be a string or a number

tia teernabachoo at gmail.com
Mon Feb 19 01:44:03 EST 2018


def get_UbiTimestamp():
	api = ApiClient(token='A1E-6l4DwwC86SDR6QRTJWXGDwshTGPHFl')
	variable = api.get_variable('5a5f80eec03f971388983b8e')
	value = variable.get_values(1)[0]
	timestamp = value.get('timestamp')
	t= mdate.epoch2num(raw)
	
	return t

def plot_temp():
	ldr= get_records()
	ys = ldr
	fig = Figure()
	axis = fig.add_subplot(1,1,1)
	axis.set_title("Light Intensity")
	axis.set_xlabel("Time")
	axis.xaxis.set_major_formatter(mdate.DateFormatter('%H:%M:%S'))
	axis.grid(True)
	time= get_UbiTimestamp()
	xs = time
	axis.plot(xs,ys)
	canvas = FigureCanvas(fig)
	output = io.BytesIO()
	canvas.print_png(output)
	response = make_response(output.getvalue())
	response.mimetype = 'image/png'
	ani= animation.FuncAnimation(fig, animate, interval=3000)
	return response

Apparently the timestamp format is giving the following errors:

Complete traceback:

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1997, in
__call__
    return self.wsgi_app(environ, start_response)
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1985, in
wsgi_app
    response = self.handle_exception(e)
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1540, in
handle_exception
    reraise(exc_type, exc_value, tb)
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1982, in
wsgi_app
    response = self.full_dispatch_request()
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1614, in
full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1517, in
handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1612, in
full_dispatch_request
    rv = self.dispatch_request()
    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1598, in
dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/pi/MatPlotLib-Flask.py", line 51, in plot_temp
    axis.plot(xs,ys)
    File "/usr/lib/python2.7/dist-packages/matplotlib/__init__.py", line
1894, in inner
    return func(ax, *args, **kwargs)
    File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_axes.py", line
1407, in plot
    self.add_line(line)
    File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line
1787, in add_line
    self._update_line_limits(line)
    File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line
1809, in _update_line_limits
    path = line.get_path()
    File "/usr/lib/python2.7/dist-packages/matplotlib/lines.py", line 989,
in get_path
    self.recache()
    File "/usr/lib/python2.7/dist-packages/matplotlib/lines.py", line 685,
in recache
    y = np.asarray(yconv, np.float_)
    File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 531,
in asarray
    return array(a, dtype, copy=False, order=order)
    TypeError: float() argument must be a string or a number



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html


More information about the Matplotlib-users mailing list