我自己的版本是:python3.9, Anaconda。安装完geopandas之后 ,anaconda就不能唤起Jupyter了
在学哔哩哔哩上的python可视化:https://www.bilibili.com/video/BV1nZ4y1H7BB?spm_id_from=333.999.0.0
①scheme报错
②legend不一样,图例不是默认放在绘图区里么,我的直接出现在外面,而且位置只能选择:top\bottom\left\right
问题相关代码,请勿粘贴截图
merge.plot(
column='3/25/22',
scheme='userdefined',
classification_kwds={'bins':[50,100,1000,2000,5000,9000,100000,100000]},
)
运行结果及报错内容
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
D:\Anaconda\lib\site-packages\geopandas\plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, categories, classification_kwds, missing_kwds, aspect, **style_kwds)
734 try:
--> 735 import mapclassify
736
ModuleNotFoundError: No module named 'mapclassify'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
\AppData\Local\Temp/ipykernel_8928/229029908.py in <module>
----> 1 merge.plot(
2
3 column='3/25/22',
4 scheme='userdefined',
5 classification_kwds={'bins':[50,100,1000,2000,5000,9000,100000,100000]},
D:\Anaconda\lib\site-packages\geopandas\plotting.py in __call__(self, *args, **kwargs)
948 kind = kwargs.pop("kind", "geo")
949 if kind == "geo":
--> 950 return plot_dataframe(data, *args, **kwargs)
951 if kind in self._pandas_kinds:
952 # Access pandas plots
D:\Anaconda\lib\site-packages\geopandas\plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, categories, classification_kwds, missing_kwds, aspect, **style_kwds)
736
737 except ImportError:
--> 738 raise ImportError(mc_err)
739
740 if mapclassify.__version__ < LooseVersion("2.4.0"):
ImportError: The 'mapclassify' package (>= 2.4.0) is required to use the 'scheme' keyword.
问题相关代码,请勿粘贴截图
merge.plot(
column='3/25/22',
#scheme='userdefined',
#classification_kwds={'bins':[50,100,1000,2000,5000,9000,100000,100000]},
legend=True,
legend_kwds=dict(location='bottom'),
)
如果改成跟up一样的:“loc=lower right”就会报错,:
merge.plot(
column='3/25/22',
#scheme='userdefined',
#classification_kwds={'bins':[50,100,1000,2000,5000,9000,100000,100000]},
legend=True,
legend_kwds=dict(loc='lower right'),
)
运行结果及报错内容
TypeError Traceback (most recent call last)
\AppData\Local\Temp/ipykernel_8928/387750221.py in <module>
----> 1 merge.plot(
2
3 column='3/25/22',
4 #scheme='userdefined',
5 #classification_kwds={'bins':[50,100,1000,2000,5000,9000,100000,100000]},
D:\Anaconda\lib\site-packages\geopandas\plotting.py in __call__(self, *args, **kwargs)
948 kind = kwargs.pop("kind", "geo")
949 if kind == "geo":
--> 950 return plot_dataframe(data, *args, **kwargs)
951 if kind in self._pandas_kinds:
952 # Access pandas plots
D:\Anaconda\lib\site-packages\geopandas\plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, categories, classification_kwds, missing_kwds, aspect, **style_kwds)
933
934 n_cmap.set_array(np.array([]))
--> 935 ax.get_figure().colorbar(n_cmap, **legend_kwds)
936
937 plt.draw()
D:\Anaconda\lib\site-packages\matplotlib\figure.py in colorbar(self, mappable, cax, ax, use_gridspec, **kw)
1174 'panchor']
1175 cb_kw = {k: v for k, v in kw.items() if k not in NON_COLORBAR_KEYS}
-> 1176 cb = cbar.Colorbar(cax, mappable, **cb_kw)
1177
1178 self.sca(current_ax)
D:\Anaconda\lib\site-packages\matplotlib\colorbar.py in __init__(self, ax, mappable, **kwargs)
1195 if isinstance(mappable, martist.Artist):
1196 _add_disjoint_kwargs(kwargs, alpha=mappable.get_alpha())
-> 1197 super().__init__(ax, **kwargs)
1198
1199 mappable.colorbar = self
D:\Anaconda\lib\site-packages\matplotlib\_api\deprecation.py in wrapper(*args, **kwargs)
469 "parameter will become keyword-only %(removal)s.",
470 name=name, obj_type=f"parameter of {func.__name__}()")
--> 471 return func(*args, **kwargs)
472
473 return wrapper
TypeError: __init__() got an unexpected keyword argument 'loc'