Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 模块';plotly.graph_objs';没有属性';Choroplethmapbox';_Python_Plotly - Fatal编程技术网

Python 模块';plotly.graph_objs';没有属性';Choroplethmapbox';

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

我正试图从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(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)中添加的,因此您需要升级