在Jupyter笔记本中,Plotly图表未显示。

83 浏览
0 Comments

在Jupyter笔记本中,Plotly图表未显示。

我已经花了几个小时来解决这个问题。我按照Plotly网站上的步骤进行操作,但图表仍然无法在笔记本中显示。

这是我的绘图代码:

colorway = ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']
data = [
    go.Scatter(
        x = immigration.columns,
        y = immigration.loc[state],
                   name=state) for state in immigration.index]
layout = go.Layout(
    title='Immigration',
    yaxis=dict(title='Immigration %'),
    xaxis=dict(title='Years'),
    colorway=colorway,
    font=dict(family='Courier New, monospace', size=18, color='#7f7f7f')
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

这是我在笔记本中导入的所有内容:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)  

0