我正试图从密谋网站https://plot.ly/python/mapbox-county-choropleth/破坏他的代码 并抛出此错误,我似乎无法解决。我已经查看了github页面,但没有成功。
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
dtype={"fips": str})
from plotly import graph_objs as go
#import plotly.graph_objects as go
fig = go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.fips, z=df.unemp,
colorscale="Viridis", zmin=0, zmax=12,
marker_opacity=0.5, marker_line_width=0))
fig.update_layout(mapbox_style="carto-positron",
mapbox_zoom=3, mapbox_center = {"lat": 37.0902, "lon": -95.7129})
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()```
答案 0 :(得分:0)
此功能已添加到最新版本的Plotly(即4.1.0)中,因此您需要进行升级。