Python 模块';plotly.graph_objs';没有属性';Choroplethmapbox';
我正试图从plotly网站上运行他的代码 它抛出了一个错误,我似乎无法解决这个问题。我已经查看了github页面,但没有成功Python 模块';plotly.graph_objs';没有属性';Choroplethmapbox';,python,plotly,Python,Plotly,我正试图从plotly网站上运行他的代码 它抛出了一个错误,我似乎无法解决这个问题。我已经查看了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(re
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()```
这是在Plotly的最新版本(4.1.0)中添加的,因此您需要升级