html如何插入形状,如何将Python绘制的图形插入到HTML文件中?

我一直在寻找方法来做到这一点,但我似乎没有得到任何有用的答案在网上,所以我不得不直接问这里。在

我想要的很简单:处理来自CSV的一些数据,将其绘制成图形并发布到我的HTML中。我不拥有任何网络域,HTML被放在一个共享驱动器中,可以被某些允许使用Chrome的人群查看。在

下面是我的python代码片段:import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from jinja2 import Environment, FileSystemLoader

import plotly as py

import numpy as np

import plotly.tools as plotly_tools

import plotly.plotly as py

from plotly.graph_objs import *

def dashboard_plot_graph():

html_template = __Html_path__.get_template("PublishPG.html")

curr_mcl_res = pd.read_csv(os.path.join(__Result_path__, __Chart_csv__))

print curr_mcl_res.head()

x = curr_mcl_res['TestSuite']

my_plot = curr_mcl_res.plot(x, kind='bar', stacked=True, title='Latest Trend')

fig = my_plot.get_figure()

fig.savefig("./my_img.png")

html_template_vars = {"curr_mcl_div_placeholder": curr_mcl_res.to_html()}

html_out = html_template.render(html_template_vars)

f = open ('file.html', 'w')

f.write( html_out )

f.close()

plt.show()

下面是我的HTML代码片段:

^{pr2}$

这是我希望在我的网页上看到的情节:

Fjiao.png

我试过:遵循在线教程,似乎说可以把绘图插入到HTML。。。但是失败了。。。我能做的就是

插入数据帧(表),如上面的代码段所示。在

我尝试了一些解决方法,比如将绘制的图形另存为图像,并尝试将图像插入到html中。但它不允许

出于安全原因,从本地驱动器获取映像。它只能

如果我把图片上传到云的某个地方,就拉图片/

web域。但这些数据不适合在任何社交网站上公开

媒体网站。在

有什么建议让我克服这个限制吗?在

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值