(GeoPandasでロードされた)とPandasデータフレーム(プロットしたいデータを含む)のmerge
間にあるこのGeoPandasデータフレームがあります。shapefile
import matplotlib.pyplot as plt
import geopandas as gpd
import pandas as pd
[...]
df_for_map = geopandas_shp_df.merge(pandas_data_df, on='neighborhood')
print df_for_map.head(1)
与えます:
geometry id neighborhood \
0 POLYGON ((XX.XXX YY.YYY, ... 1 My_Neighborhood_Key_Representing_A_Polygon
mean
0 ZZ.ZZZ
GeoPandas のドキュメント (ここ: http://geopandas.readthedocs.io/en/stable/mapping.htmlおよびgpd.plot
関数のドキュメント) によると、クロロプレス マップをプロットしたい場合は、次のようにする必要があります。
df_for_map.plot(column='mean', cmap=plt)
plt.savefig('figure_file_path')
しかし、これにより次のエラーが発生します。
Traceback (most recent call last):
File "./MY_PYTHON_SCRIPT.py", line XXX, in <module>
df_for_map.plot(column='mean', cmap=plt)
File "/usr/local/lib/python2.7/site-packages/geopandas/geodataframe.py", line 447, in plot
return plot_dataframe(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/geopandas/plotting.py", line 261, in plot_dataframe
cmap = norm_cmap(values, cmap, Normalize, cm, vmin=vmin, vmax=vmax)
File "/usr/local/lib/python2.7/site-packages/geopandas/plotting.py", line 372, in norm_cmap
n_cmap = cm.ScalarMappable(norm=norm, cmap=cmap)
File "/usr/local/lib/python2.7/site-packages/matplotlib/cm.py", line 201, in __init__
self.cmap = get_cmap(cmap)
File "/usr/local/lib/python2.7/site-packages/matplotlib/cm.py", line 166, in get_cmap
% (name, ', '.join(sorted(cmap_d.keys()))))
ValueError: Colormap <module 'matplotlib.pyplot' from '/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc'> is not recognized. Possible values are: Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, inferno, inferno_r, jet, jet_r, magma, magma_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, seismic, seismic_r, spectral, spectral_r, spring, spring_r, summer, summer_r, terrain, terrain_r, viridis, viridis_r, winter, winter_r
matplotlib
で作業するために何をする必要があるのか わかりませんかGeoPandas
?