【发布时间】:2020-07-03 01:37:19
【问题描述】:
所以我不想使用 plt.savefig 并想动态渲染我的图表。请看这个,它正在保存图形然后渲染 -
def get_graph(pressure, flow, fr_value):
fig = plt.figure()
img=io.BytesIO()
plt.plot(flow, pressure)
plt.savefig(img,format='png')
img.seek(0)
plot_url = base64.b64encode(img.getvalue()).decode()
return plot_url
还有我的烧瓶应用 -
plot_url = graph.get_graph(int(pressure), int(flow), fr_value) # figure from get_graph url
return render_template('plot.html', url=plot_url)
html -
<body>
<img src="data:image/png;base64,{{url}}" alt="Chart" height="auto" width="60%">
</body>
【问题讨论】:
标签: python html matplotlib flask