成功解决AttributeError: ‘PathCollection‘ object has no property ‘n_levels‘
生活随笔
收集整理的這篇文章主要介紹了
成功解决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函數中,即可!
def kdeplot Found at: seaborn.distributions@_deprecate_positional_args def kdeplot(x= # Allow positional x, because behavior will not change with reorgNone, *, y=None, shade= # Note "soft" deprecation, explained belowNone, vertical= # DeprecatedFalse, kernel= # DeprecatedNone, bw= # DeprecatedNone, gridsize= # TODO maybe depend on uni/bivariate?200, cut=3, clip=None, legend=True, cumulative=False, shade_lowest= # Deprecated, controlled with levels nowNone, cbar=False, cbar_ax=None, cbar_kws=None, ax=# New paramsNone, weights= # TODO note that weights is grouped with semanticsNone, hue=None, palette=None, hue_order=None, hue_norm=None, multiple="layer", common_norm=True, common_grid=False, levels=10, thresh=.05, bw_method="scott", bw_adjust=1, log_scale=None, color=None, fill=# Renamed paramsNone, data=None, data2=None, **kwargs):# Handle deprecation of `data2` as name for y variableif data2 is not None:y = data2# If `data2` is present, we need to check for the `data` kwarg being# used to pass a vector for `x`. We'll reassign the vectors and warn.# We need this check because just passing a vector to `data` is now# technically valid.x_passed_as_data = x is None and data is not None and np.ndim(data) == 1if x_passed_as_data:msg = "Use `x` and `y` rather than `data` `and `data2`"x = dataelse:msg = "The `data2` param is now named `y`; please update your code"warnings.warn(msg, FutureWarning)# Handle deprecation of `vertical`if vertical:msg = "The `vertical` parameter is deprecated and will be removed in a "\"future version. Assign the data to the `y` variable instead."warnings.warn(msg, FutureWarning)x, y = y, x# Handle deprecation of `bw`if bw is not None:msg = "The `bw` parameter is deprecated in favor of `bw_method` and "\f"`bw_adjust`. Using {bw} for `bw_method`, but please "\"see the docs for the new parameters and update your code."warnings.warn(msg, FutureWarning)bw_method = bw# Handle deprecation of `kernel`if kernel is not None:msg = "Support for alternate kernels has been removed. "\"Using Gaussian kernel."warnings.warn(msg, UserWarning)# Handle deprecation of shade_lowestif shade_lowest is not None:if shade_lowest:thresh = 0msg = "`shade_lowest` is now deprecated in favor of `thresh`. "\f"Setting `thresh={thresh}`, but please update your code."warnings.warn(msg, UserWarning)# Handle `n_levels`# This was never in the formal API but it was processed, and appeared in an# example. We can treat as an alias for `levels` now and deprecate later.levels = kwargs.pop("n_levels", levels)# Handle "soft" deprecation of shade `shade` is not really the right# terminology here, but unlike some of the other deprecated parameters it# is probably very commonly used and much hard to remove. This is therefore# going to be a longer process where, first, `fill` will be introduced and# be used throughout the documentation. In 0.12, when kwarg-only# enforcement hits, we can remove the shade/shade_lowest out of the# function signature all together and pull them out of the kwargs. Then we# can actually fire a FutureWarning, and eventually remove.if shade is not None:fill = shade# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #p = _DistributionPlotter(data=data, variables=_DistributionPlotter.get_semantics(locals()))p.map_hue(palette=palette, order=hue_order, norm=hue_norm)if ax is None:ax = plt.gca()# Check for a specification that lacks x/y data and return earlyif not p.has_xy_data:return ax# Pack the kwargs for statistics.KDEestimate_kws = dict(bw_method=bw_method, bw_adjust=bw_adjust, gridsize=gridsize, cut=cut, clip=clip, cumulative=cumulative)p._attach(ax, allowed_types=["numeric", "datetime"], log_scale=log_scale)if p.univariate:plot_kws = kwargs.copy()if color is not None:plot_kws["color"] = colorp.plot_univariate_density(multiple=multiple, common_norm=common_norm, common_grid=common_grid, fill=fill, legend=legend, estimate_kws=estimate_kws, **plot_kws)else:p.plot_bivariate_density(common_norm=common_norm, fill=fill, levels=levels, thresh=thresh, legend=legend, color=color, cbar=cbar, cbar_ax=cbar_ax, cbar_kws=cbar_kws, estimate_kws=estimate_kws, **kwargs)return ax?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的成功解决AttributeError: ‘PathCollection‘ object has no property ‘n_levels‘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Py之Seaborn:数据可视化Seab
- 下一篇: 成功解决pandas读取文件中不读取第一