
我无法让figure_factory识别包含create_choropleth的county_choroplet模块(我相信在第512行)。
我只是在使用https://plot.ly/python/county-choropleth/网站上的一个基本例子
编辑:我试图通过导入以下内容来实现来自上一个question的建议:
from plotly.figure_factory._county_choropleth import create_choropleth然后:fig = create_choropleth(fips=fips, values=values) py.ploy(fig, filename='basic-choropleth') py.iplot(fig, filename='choropleth of some cali counties - full usa scope')
但我收到以下错误(如图所示):
文件"C:\ProgramData\Miniconda3\lib\site-packages\fiona__init__.py",第162行,在打开的IOError中(“没有这样的文件或目录:%r”%IOError)
'C:\ProgramData\Miniconda3\lib\site-packages\plotly\package_data\gz_2010_us_050_00_500k.shp‘:OSError:没有这样的文件或目录:


发布于 2018-09-18 20:31:52
所以,我们所做的就是在C:\ProgramData\Miniconda3\pkgs\plotly-3.1.1-py36h28b3542_0\Lib\site-packages\plotly中传输文件
至:
C:\ProgramData\Miniconda3\Lib\site-packages\plotly然后我运行了代码:
import plotly.plotly as py
from plotly.figure_factory._county_choropleth import create_choropleth
py.sign_in('chessybo', 'XXXXXXXXXXX')
fips = ['06021', '06023', '06027',
'06029', '06033', '06059',
'06047', '06049', '06051',
'06055', '06061']
values = range(len(fips))
#fig = ff.create_choropleth(fips=fips, values=values)
fig = create_choropleth(fips=fips, values=values)
#py.plotly(fig, filename='basic-choropleth')
py.plot(fig, filename='choropleth of some cali counties - full usa scope')而且起作用了。
发布于 2018-09-18 14:55:56
在执行此代码之后,您将得到什么:
# import necessary libraries
import geopandas
import shapely
import shapefile
import plotly
from plotly.figure_factory._county_choropleth import create_choropleth
# Check your plotly version
print(plotly.__version__, geopandas.__version__,shapely.__version__,shapefile.__version__)
# Data
fips = ['06021','06023','06027',
'06029','06033','06059',
'06047','06049','06051',
'06055','06061']
values = range(len(fips))
# Create fig
fig = create_choropleth(fips=fips, values=values)
# Plot in offline mode and save plot in your Python script folder
plotly.offline.plot(fig, filename='choropleth_usa.html')在我的例子中,脚本返回以下内容:

https://stackoverflow.com/questions/52378152
复制相似问题