我有以下列表数据: 第一个元素是PM级别,第二个元素是日期。
[
['83', '89', '88', '86', '85', '83', '86', '85', '86', '89', '88', '89',
'90', '88', '85', '85', '84', '80', '85', '-', '103', '107', '104', '106']
['2017-12-29 15:00', '2017-12-29 16:00', '2017-12-29 17:00', '2017-12-29 18:00',
'2017-12-29 19:00', '2017-12-29 20:00', '2017-12-29 21:00', '2017-12-29 22:00',
'2017-12-29 23:00', '2017-12-29 24:00', '2017-12-30 01:00', '2017-12-30 02:00',
'2017-12-30 03:00', '2017-12-30 04:00', '2017-12-30 05:00', '2017-12-30 06:00',
'2017-12-30 07:00', '2017-12-30 08:00', '2017-12-30 09:00', '2017-12-30 11:00',
'2017-12-30 12:00', '2017-12-30 13:00', '2017-12-30 14:00', '2017-12-30 15:00']]
这是我程序相关片段的一部分。
@app.route('/pm25')
def pm25_graph():
data_list = Display.data_retrieval()
pm10, pm25, dates = data_list
fig = Figure(figsize=(12, 5), dpi=100)
ax = fig.add_subplot(111, title="PM 25 Level")
ax.plot_date(dates, pm25, '-')
fig.autofmt_xdate()
canvas = FigureCanvas(fig)
png_output = BytesIO()
canvas.print_png(png_output)
response = make_response(png_output.getvalue())
response.headers['Content-Type'] = 'image/png'
return response
当我运行程序时,我得到了:
请有人帮我解决这个问题。非常感谢提前。