我正在尝试从此页面运行地图制作教程:
http://www.bigendiandata.com/2017-06-27-Mapping_in_Jupyter/
并且我遇到以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-851f26d70bd3> in <module>()
2 #import plotly.plotly as py
3 #import plotly.graph_objs as go
----> 4 plotly.offline.init_notebook_mode()
5
6 import pandas as pd
AttributeError: 'module' object has no attribute 'offline'
我正在尝试运行以下代码:
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
plotly.offline.init_notebook_mode()
import pandas as pd
coords = pd.concat([housing['latitude'], housing['longitude'],
housing['population']], axis=1)
coords = coords.sample(frac=0.1, replace=True)
cases = []
colors = ['rgb(239,243,255)','rgb(189,215,231)','rgb(107,174,214)','rgb(33,113,181)']
months = {6:'June',7:'July',8:'Aug',9:'Sept'}
for i in range(6,10)[::-1]:
cases.append(go.Scattergeo( .
lon = coords['longitude'],
lat = coords['latitude'],
marker = dict(
size = coords['population']/1000,
color = 'colors[i-6]',
opacity = .4,
line = dict(width = 0)
),
) )
cases[0]['mode'] = 'markers'
layout = go.Layout(
title = 'Hey look! It\'s a scatter plot on a map!',
geo = dict(
resolution = 100,
scope = 'usa',
showframe = False,
showcoastlines = True,
showland = True,
landcolor = "rgb(229, 229, 229)",
countrycolor = "rgb(255, 255, 255)" ,
coastlinecolor = "rgb(255, 255, 255)",
projection = dict(
type = 'Mercator'
),
lonaxis = dict( range= [ -124.0, -113.0 ] ),
lataxis = dict( range= [ 32.0, 43.0 ] ),
),
legend = dict(
traceorder = 'reversed'
)
)
fig = go.Figure(layout=layout, data=cases)
plotly.offline.iplot(fig, validate=False, filename='iantest')
我在哪里弄糟?我试图安装plotly,并且help(“ plotly”)提供了很多属性,但对于脱机却一无所获。
谢谢!