Plotly Ipython-display(HTML)函数未显示HTML文件

Plotly Ipython-display(HTML)函数未显示HTML文件,python,ipython,plotly,Python,Ipython,Plotly,我正在使用plotly库创建图像,并尝试以HTML显示。我已经格式化的HTML格式的图像。但是display(HTML(report\u HTML))code没有显示HTML页面 我正在使用Python3.5和PyIDE。我没有使用iPython笔记本 源代码: 我没有得到任何错误。我只是得到以下输出 IPython.core.display.HTML对象 很抱歉回复得太晚,代码对我来说非常适合,让我分享我的示例,基本区别是我使用了plotly.graph_objs下的figure对象,而不是f

我正在使用plotly库创建图像,并尝试以HTML显示。我已经格式化的HTML格式的图像。但是
display(HTML(report\u HTML))
code没有显示HTML页面

我正在使用Python3.5和PyIDE。我没有使用iPython笔记本

源代码:

我没有得到任何错误。我只是得到以下输出

IPython.core.display.HTML对象


很抱歉回复得太晚,代码对我来说非常适合,让我分享我的示例,基本区别是我使用了plotly.graph_objs下的
figure对象,而不是
figures=[data]

代码:

from IPython.display import display, HTML, Image
import plotly.plotly as py
import base64
import plotly.graph_objs as go
py.sign_in('<<username here>>', '<<api key here>>')

# required variables
width=500
height=300

# template not provided so created my own
template = """
<div class="row">
    <div class="col-xs-12" style="text-align:center">
        {caption}
    </div>
    <div class="col-xs-12">
        <img src="data:image/png;base64,  {image}" alt="Red dot"/>
    </div>
</div>
"""

# data = go.scatter(x=df['date'], y=i, name = long_name['value'])

# using my sample data instead
trace = go.Bar(x=[2, 4, 6], y= [10, 12, 15])

# layout can also be provided, I am giving as blank
layout = dict()

# figures = [data]
# changing the above commented line to plotly figure object
fig = go.Figure(data=[trace], layout=layout)

# defining list which will contain all the plot objects
figures = []
figures.append(fig)

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.display导入显示、HTML、图像
导入plotly.plotly作为py
导入base64
导入plotly.graph_objs作为go
py.登录(“”,“”)
#必需变量
宽度=500
高度=300
#未提供模板,因此创建了我自己的模板
模板=“”“
{标题}
"""
#data=go.scatter(x=df['date'],y=i,name=long\u name['value'])
#改用我的示例数据
trace=go.Bar(x=[2,4,6],y=[10,12,15])
#布局也可以提供,我给作为空白
布局=dict()
#图=[数据]
#将上述注释线更改为plotly地物对象
图=开始图(数据=[跟踪],布局=布局)
#定义包含所有打印对象的列表
数字=[]
图.附加(图)
images=[base64.b64编码(py.image.get(figure,width=width,height=height)).decode('utf-8'),用于数字中的数字]
报告_html=“”
对于图像中的图像:
_=模板
_=\格式(图像=图像,标题='',宽度=宽度,高度=高度)
报告_html+=_
显示(HTML(报告和HTML))

您是使用plotly offline打印图像,还是使用plotly online模式,您能澄清一下吗?我使用的是plotly online模式。在公共云中保存plotly图表。我不是专业用户。我可以在线使用plotly吗?可以。有一个免费用户的社区版
from IPython.display import display, HTML, Image
import plotly.plotly as py
import base64
import plotly.graph_objs as go
py.sign_in('<<username here>>', '<<api key here>>')

# required variables
width=500
height=300

# template not provided so created my own
template = """
<div class="row">
    <div class="col-xs-12" style="text-align:center">
        {caption}
    </div>
    <div class="col-xs-12">
        <img src="data:image/png;base64,  {image}" alt="Red dot"/>
    </div>
</div>
"""

# data = go.scatter(x=df['date'], y=i, name = long_name['value'])

# using my sample data instead
trace = go.Bar(x=[2, 4, 6], y= [10, 12, 15])

# layout can also be provided, I am giving as blank
layout = dict()

# figures = [data]
# changing the above commented line to plotly figure object
fig = go.Figure(data=[trace], layout=layout)

# defining list which will contain all the plot objects
figures = []
figures.append(fig)

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))