【发布时间】:2019-08-20 18:10:12
【问题描述】:
我想在 geopandas.plot() 函数中调整颜色条的大小。
我阅读了 geopandas 的关于颜色条调整的 Github 页面。 https://github.com/geopandas/geopandas/pull/894
然后编写如下代码
import geopandas as gp
from mpl_toolkits.axes_grid1 import make_axes_locatable
import matplotlib.pyplot as plt
shp=gp.read_file("PropRepShape.shp",encoding="UTF-8")
fig, ax = plt.subplots(1,1)
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.2) # depends on the user needs
shp.plot("P_NUM",ax=ax,cax=cax,legend=True,cmap=cmap)
“PropRepShape.shp”可从 https://github.com/ShingObt/2019JapanHOCElectionMap/tree/master/Shapefile
然后我最终收到错误消息
AttributeError: Unknown property cax
通过删除cax=cax,我可以生成地图,但颜色条的大小没有调整。
能否告诉我在 gp.plot 中成功使用 cax 参数的方法?
【问题讨论】:
-
您使用的是哪个版本的 geopandas?
-
@mishsx 请不要像您在编辑此问题时那样滥用粗体格式。见meta.stackoverflow.com/q/327171/6296561
-
我使用 geopandas 0.4.0。