【发布时间】:2018-08-15 09:50:56
【问题描述】:
我目前正在将两个 matplotlib 图保存到 Flask 应用程序的 /static 文件夹中。
但是,当它们以 HTML 呈现时。他们都只渲染第一张图像。不是我所期望的两个单独的图像。
name_img_1 = 'static/1.png?%d' % time.time()
name_img_2 = 'static/2.png?%d' % time.time()
plt.plot( 'Time stamp 1', 'pred1', data=data, linestyle='-', marker='o')
plt.title(' classifier 1')
plt.axhline(y=0.55,label='Threshold (=0.55)')
plt.legend()
plt.savefig(name_img_1,format='png')
plt.plot( 'Time stamp 1', 'pred2', data=data, linestyle='-', marker='o')
plt.title(' classifier 1')
plt.axhline(y=0.55,label='Threshold (=0.72)')
plt.legend()
plt.savefig(name_img_2,format='png')
return render_template("hello.html",user_image=name_img_1,user_image_2=name_img_3,form=form)
HTML 代码
<img src="{{ user_image }}" alt="User Image">
<img src="{{ user_image_2 }}" alt="User Imageq23">
我尝试创建两个单独的静态文件夹和子目录,但都不起作用。
【问题讨论】:
标签: python python-3.x matplotlib flask