成功解决AttributeError: ‘PathCollection‘ object has no property ‘n_levels‘


棒棒糖现代
棒棒糖现代 2022-09-19 11:31:30 64496
分类专栏: 资讯

成功解决AttributeError: 'PathCollection' object has no property 'n_levels'

目录

解决问题

解决思路

解决方法


解决问题

AttributeError: 'PathCollection' object has no property 'n_levels'

解决思路

属性错误:“PathCollection”对象没有属性“n_levels”

解决方法

def scatter Found at: matplotlib.pyplot中并没有n_levels参数!很可能是代码写的有误,这个参数存在在中,如果必须使用n_levels参数,那么应该加到sns.kdeplot函数中,即可!

  1. def kdeplot Found at: seaborn.distributions
  2. -meta">@_deprecate_positional_args
  3. def kdeplot(
  4. x= Allow positional x, because behavior will not change with reorg
  5. None,
  6. *, y=None,
  7. shade= Note "soft" deprecation, explained below
  8. None, vertical= Deprecated
  9. False, kernel= Deprecated
  10. None, bw= Deprecated
  11. None, gridsize= TODO maybe depend on uni/bivariate?
  12. 200, cut=3, clip=None, legend=True, cumulative=False,
  13. shade_lowest= Deprecated, controlled with levels now
  14. None, cbar=False, cbar_ax=None, cbar_kws=None,
  15. ax=
  16. New params
  17. None, weights= TODO note that weights is grouped with
  18. semantics
  19. None, hue=None, palette=None, hue_order=None,
  20. hue_norm=None,
  21. multiple="layer", common_norm=True, common_grid=False,
  22. levels=10, thresh=.05,
  23. bw_method="scott", bw_adjust=1, log_scale=None,
  24. color=None, fill=
  25. Renamed params
  26. None, data=None, data2=None, **
  27. kwargs):
  28. Handle deprecation of `data2` as name for y variable
  29. if data2 is not None:
  30. y = data2
  31. If `data2` is present, we need to check for the `data` kwarg being
  32. used to pass a vector for `x`. We'll reassign the vectors and
  33. warn.
  34. We need this check because just passing a vector to `data` is
  35. now
  36. technically valid.
  37. x_passed_as_data = x is None and data is not None and np.ndim
  38. (data) == 1
  39. if x_passed_as_data:
  40. msg = "Use `x` and `y` rather than `data` `and `data2`"
  41. x = data
  42. else:
  43. msg = "The `data2` param is now named `y`; please update your
  44. code"
  45. warnings.warn(msg, FutureWarning)
  46. Handle deprecation of `vertical`
  47. if vertical:
  48. msg = "The `vertical` parameter is deprecated and will be
  49. removed in a "\
  50. "future version. Assign the data to the `y` variable instead."
  51. warnings.warn(msg, FutureWarning)
  52. x, y = y, x
  53. Handle deprecation of `bw`
  54. if bw is not None:
  55. msg = "The `bw` parameter is deprecated in favor of
  56. `bw_method` and "\
  57. f"`bw_adjust`. Using -subst">{bw} for `bw_method`, but please "\
  58. "see the docs for the new parameters and update your code."
  59. warnings.warn(msg, FutureWarning)
  60. bw_method = bw
  61. Handle deprecation of `kernel`
  62. if kernel is not None:
  63. msg = "Support for alternate kernels has been removed. "\
  64. "Using Gaussian kernel."
  65. warnings.warn(msg, UserWarning)
  66. Handle deprecation of shade_lowest
  67. if shade_lowest is not None:
  68. if shade_lowest:
  69. thresh = 0
  70. msg = "`shade_lowest` is now deprecated in favor of `thresh`. "\
  71. f"Setting `thresh=-subst">{thresh}`, but please update your code."
  72. warnings.warn(msg, UserWarning)
  73. Handle `n_levels`
  74. This was never in the formal API but it was processed, and
  75. appeared in an
  76. example. We can treat as an alias for `levels` now and deprecate
  77. later.
  78. levels = kwargs.pop("n_levels", levels)
  79. Handle "soft" deprecation of shade `shade` is not really the right
  80. terminology here, but unlike some of the other deprecated
  81. parameters it
  82. is probably very commonly used and much hard to remove. This
  83. is therefore
  84. going to be a longer process where, first, `fill` will be introduced
  85. and
  86. be used throughout the documentation. In 0.12, when kwarg-only
  87. enforcement hits, we can remove the shade/shade_lowest out of
  88. the
  89. function signature all together and pull them out of the kwargs.
  90. Then we
  91. can actually fire a FutureWarning, and eventually remove.
  92. if shade is not None:
  93. fill = shade
  94. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  95. p = _DistributionPlotter(
  96. data=data,
  97. variables=_DistributionPlotter.get_semantics(locals()))
  98. p.map_hue(palette=palette, order=hue_order, norm=hue_norm)
  99. if ax is None:
  100. ax = plt.gca()
  101. Check for a specification that lacks x/y data and return early
  102. if not p.has_xy_data:
  103. return ax
  104. Pack the kwargs for statistics.KDE
  105. estimate_kws = dict(bw_method=bw_method,
  106. bw_adjust=bw_adjust,
  107. gridsize=gridsize,
  108. cut=cut,
  109. clip=clip,
  110. cumulative=cumulative)
  111. p._attach(ax, allowed_types=["numeric", "datetime"],
  112. log_scale=log_scale)
  113. if p.univariate:
  114. plot_kws = kwargs.copy()
  115. if color is not None:
  116. plot_kws["color"] = color
  117. p.plot_univariate_density(multiple=multiple,
  118. common_norm=common_norm, common_grid=common_grid,
  119. fill=fill, legend=legend, estimate_kws=estimate_kws, **plot_kws)
  120. else:
  121. p.plot_bivariate_density(common_norm=common_norm, fill=fill,
  122. levels=levels, thresh=thresh, legend=legend, color=color, cbar=cbar,
  123. cbar_ax=cbar_ax, cbar_kws=cbar_kws, estimate_kws=estimate_kws,
  124. **kwargs)
  125. return ax

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=2077
赞同 0
评论 0 条
棒棒糖现代L0
粉丝 0 发表 3 + 关注 私信
上周热门
Kingbase用户权限管理  2036
信刻全自动光盘摆渡系统  1767
信刻国产化智能光盘柜管理系统  1436
银河麒麟添加网络打印机时,出现“client-error-not-possible”错误提示  1038
银河麒麟打印带有图像的文档时出错  944
银河麒麟添加打印机时,出现“server-error-internal-error”  733
麒麟系统也能完整体验微信啦!  672
统信桌面专业版【如何查询系统安装时间】  651
统信操作系统各版本介绍  644
统信桌面专业版【全盘安装UOS系统】介绍  614
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
信创开放社区邀请他人注册的具体步骤如下 15
如何玩转信创开放社区—从小白进阶到专家 15
方德桌面操作系统 14
我有15积分有什么用? 13
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

添加我为好友,拉您入交流群!

请使用微信扫一扫!