0
我正在Jupyter Notebook.I想繪製choropleth,但它顯示空empty.I我正在與線下plotly.It工作在choropleth成功的genrated圖成功,但當我試圖離線它顯示我空的output.please告訴我我是如何解決這個錯誤。 這裏是我的代碼Jupyter筆記本沒有使用情節陰謀輸出
from plotly.graph_objs import * from plotly.offline import download_plotlyjs, init_notebook_mode, iplot from plotly.offline.offline import _plot_html init_notebook_mode(connected=True) for col in state_df.columns: state_df[col] = state_df[col].astype(str) scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\ [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']] state_df['text'] = state_df['StateCode'] + '<br>' +'TotalPlans '+state_df['TotalPlans'] data = [ dict( type='choropleth', colorscale = scl, autocolorscale = False, locations = state_df['StateCode'], z = state_df['TotalPlans'].astype(float), locationmode = 'USA-states', text = state_df['text'], marker = dict( line = dict ( color = 'rgb(255,255,255)', width = 2 ) ), colorbar = dict( title = "Millions USD" ) ) ] layout = dict( title = 'Plan by States', geo = dict( scope='usa', projection=dict(type='albers usa'), showlakes = True, lakecolor = 'rgb(255, 255, 255)', ), ) fig = dict(data=data, layout=layout) plotly.offline.iplot(fig)