用烧瓶完全脱机 [英] Plotly offline with flask

查看:74
本文介绍了用烧瓶完全脱机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在烧瓶中离线使用Plot.我知道Plotly可以脱机使用Ipython Notebook,我可以将Plotly脱机使用flask吗? 如果没有,有人可以建议我在烧瓶中使用哪个python库进行3D可视化(离线库)

How can I use plotly offline with flask . I know that plotly can be used offline with Ipython notebook , Can I use Plotly offline with flask ? If not , can someone please suggest which python library can I use for 3 D visualisation in flask (offline library)

推荐答案

您要执行的操作是使函数以html <div>的形式返回离线绘图"结果.为此,请使用output_type ="div"参数调用offline.plot()方法.这将返回一个纯字符串,然后您可以将其放入任何flask模板中,并显示图形!

What you want to do is make functions that return the offline "plot" result as a html <div>. To do this, you call the offline.plot() method with the output_type="div" argument. This will return a pure string that you can then put in any flask template, and it will show the graph!

此外,请确保在您的静态文件中包含plotly.js库,并在显示图形的html页面中链接到它们.

Also, make sure to include the plotly.js library in your static files and link to them in your html pages that show graphs.

这是我在说的一个例子:

This is an example of what I'm saying:

fig = go.Figure(data=barChart, layout=barLayout)

div = offplot.plot(fig, show_link=False, output_type="div", include_plotlyjs=False)

return div

这篇关于用烧瓶完全脱机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆