我正在使用plotly library创建图像,并尝试以HTML格式显示。我已经将图像格式化为HTML格式。但是display(HTML(report_html))
代码没有显示HTML页面。在
我使用的是python3.5和pycharmide。我没有用iPython笔记本。在
源代码:
from IPython.display import display, HTML, Image
import plotly.plotly as py
from plotly.offline import init_notebook_mode
init_notebook_mode()
data = go.scatter(x=df['date'], y=i, name = long_name['value'])
figures = [data]
images = [base64.b64encode(py.image.get(figure, width=width,height=height)).decode('utf-8') for figure in figures]
report_html = ''
for image in images:
_ = template
_ = _.format(image=image, caption='', width=width, height=height)
report_html += _
display(HTML(report_html))
我没有收到任何错误。我只是得到以下输出
IPython.core.display.HTML object
很抱歉迟来的回复,代码对我来说非常适合,让我分享我的示例,基本区别是我使用了}
figure object under plotly.graph_objs
而不是{代码:
相关问题 更多 >
编程相关推荐