zeoyzhang 2022-03-28 20:31 采纳率: 0%
浏览 297
已结题

Python可视化,Jupyter碰到scheme不能用

我自己的版本是: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'),
       
)

img


如果改成跟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'

我的解答思路和尝试过的方法
我想要达到的结果

img

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 4月5日
    • 修改了问题 3月28日
    • 修改了问题 3月28日
    • 修改了问题 3月28日
    • 展开全部

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么