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

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


 

相关文章
|
3月前
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
367 0
|
6月前
|
Python Windows
xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】
xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】
117 0
|
3月前
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
92 0
|
4月前
|
数据采集
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
246 0
|
8月前
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
86 0
yolov7—tensorrt报错AttributeError: ‘NoneType‘ object has no attribute ‘execute_v2‘已解决。
|
8月前
|
PyTorch 算法框架/工具
已解决虚拟机yolov5报错:AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
已解决虚拟机yolov5报错:AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
216 0
已解决虚拟机yolov5报错:AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
|
8月前
报错AttributeError: Can‘t pickle local object ‘Worker.__init__.<locals>.<lambda>‘解决办法
报错AttributeError: Can‘t pickle local object ‘Worker.__init__.<locals>.<lambda>‘解决办法
229 0
|
8月前
|
Python
AttributeError: 'dict' object has no attribute 'has_key'
AttributeError: 'dict' object has no attribute 'has_key'
|
11月前
|
Python
Python 报错AttributeError: ‘str‘ object has no attribute ‘decode‘解决办法
Python 报错AttributeError: ‘str‘ object has no attribute ‘decode‘解决办法
|
11月前
解决AttributeError: ‘model‘ object has no attribute ‘copy‘
原因是没有使用model.state_dict()进行模型保存,但是使用了model.load_state_dict()加载模型。这两者要配套使用。
201 0