成功解决TypeError: distplot() got an unexpected keyword argument 'y'

目录

解决问题

解决思路

解决方法


解决问题

TypeError: distplot() got an unexpected keyword argument 'y'

解决思路

类型错误:distplot()得到了一个意外的关键字参数'y'

解决方法

fg=sns.JointGrid(x=cols[0],y=cols[1],data=data_frame,)
fg.plot_marginals(sns.distplot)

distplot()函数中,只接受一个输入数据,即有x,没有y

def distplot Found at: seaborn.distributionsdef distplot(a=None, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kws=None, kde_kws=None, rug_kws=None, fit_kws=None, color=None, vertical=False, norm_hist=False, axlabel=None, label=None, ax=None, x=None):"""DEPRECATED: Flexibly plot a univariate distribution of observations... warning::This function is deprecated and will be removed in a future version.Please adapt your code to use one of two new functions:- :func:`displot`, a figure-level function with a similar flexibilityover the kind of plot to draw- :func:`histplot`, an axes-level function for plotting histograms,including with kernel density smoothingThis function combines the matplotlib ``hist`` function (with automaticcalculation of a good default bin size) with the seaborn :func:`kdeplot`and :func:`rugplot` functions. It can also fit ``scipy.stats``distributions and plot the estimated PDF over the data.Parameters----------a : Series, 1d-array, or list.Observed data. If this is a Series object with a ``name`` attribute,the name will be used to label the data axis.bins : argument for matplotlib hist(), or None, optionalSpecification of hist bins. If unspecified, as reference rule is usedthat tries to find a useful default.hist : bool, optionalWhether to plot a (normed) histogram.kde : bool, optionalWhether to plot a gaussian kernel density estimate.rug : bool, optionalWhether to draw a rugplot on the support axis.fit : random variable object, optionalAn object with `fit` method, returning a tuple that can be passed to a`pdf` method a positional arguments following a grid of values toevaluate the pdf on.hist_kws : dict, optionalKeyword arguments for :meth:`matplotlib.axes.Axes.hist`.kde_kws : dict, optionalKeyword arguments for :func:`kdeplot`.rug_kws : dict, optionalKeyword arguments for :func:`rugplot`.color : matplotlib color, optionalColor to plot everything but the fitted curve in.vertical : bool, optionalIf True, observed values are on y-axis.norm_hist : bool, optionalIf True, the histogram height shows a density rather than a count.This is implied if a KDE or fitted density is plotted.axlabel : string, False, or None, optionalName for the support axis label. If None, will try to get itfrom a.name if False, do not set a label.label : string, optionalLegend label for the relevant component of the plot.ax : matplotlib axis, optionalIf provided, plot on this axis.Returns-------ax : matplotlib AxesReturns the Axes object with the plot for further tweaking.See Also--------kdeplot : Show a univariate or bivariate distribution with a kerneldensity estimate.rugplot : Draw small vertical lines to show each observation in adistribution.Examples--------Show a default plot with a kernel density estimate and histogram with binsize determined automatically with a reference rule:.. plot:::context: close-figs>>> import seaborn as sns, numpy as np>>> sns.set_theme(); np.random.seed(0)>>> x = np.random.randn(100)>>> ax = sns.distplot(x)Use Pandas objects to get an informative axis label:.. plot:::context: close-figs>>> import pandas as pd>>> x = pd.Series(x, name="x variable")>>> ax = sns.distplot(x)Plot the distribution with a kernel density estimate and rug plot:.. plot:::context: close-figs>>> ax = sns.distplot(x, rug=True, hist=False)Plot the distribution with a histogram and maximum likelihood gaussiandistribution fit:.. plot:::context: close-figs>>> from scipy.stats import norm>>> ax = sns.distplot(x, fit=norm, kde=False)Plot the distribution on the vertical axis:.. plot:::context: close-figs>>> ax = sns.distplot(x, vertical=True)Change the color of all the plot elements:.. plot:::context: close-figs>>> sns.set_color_codes()>>> ax = sns.distplot(x, color="y")Pass specific parameters to the underlying plot functions:.. plot:::context: close-figs>>> ax = sns.distplot(x, rug=True, rug_kws={"color": "g"},...                   kde_kws={"color": "k", "lw": 3, "label": "KDE"},...                   hist_kws={"histtype": "step", "linewidth": 3,...                             "alpha": 1, "color": "g"})"""if kde and not hist:axes_level_suggestion = "`kdeplot` (an axes-level function for kernel density plots)."else:axes_level_suggestion = "`histplot` (an axes-level function for histograms)."msg = "`distplot` is a deprecated function and will be removed in a future version. "\"Please adapt your code to use either `displot` (a figure-level function with "\"similar flexibility) or " + axes_level_suggestionwarnings.warn(msg, FutureWarning)if ax is None:ax = plt.gca()# Intelligently label the support axislabel_ax = bool(axlabel)if axlabel is None and hasattr(a, "name"):axlabel = a.nameif axlabel is not None:label_ax = True# Support new-style APIif x is not None:a = x# Make a a 1-d float arraya = np.asarray(a, float)if a.ndim > 1:a = a.squeeze()# Drop null values from arraya = remove_na(a)# Decide if the hist is normednorm_hist = norm_hist or kde or fit is not None# Handle dictionary defaultshist_kws = {} if hist_kws is None else hist_kws.copy()kde_kws = {} if kde_kws is None else kde_kws.copy()rug_kws = {} if rug_kws is None else rug_kws.copy()fit_kws = {} if fit_kws is None else fit_kws.copy()# Get the color from the current color cycleif color is None:if vertical:line, = ax.plot(0, a.mean())else:line, = ax.plot(a.mean(), 0)color = line.get_color()line.remove()# Plug the label into the right kwarg dictionaryif label is not None:if hist:hist_kws["label"] = labelelif kde:kde_kws["label"] = labelelif rug:rug_kws["label"] = labelelif fit:fit_kws["label"] = labelif hist:if bins is None:bins = min(_freedman_diaconis_bins(a), 50)hist_kws.setdefault("alpha", 0.4)hist_kws.setdefault("density", norm_hist)orientation = "horizontal" if vertical else "vertical"hist_color = hist_kws.pop("color", color)ax.hist(a, bins, orientation=orientation, color=hist_color, **hist_kws)if hist_color != color:hist_kws["color"] = hist_colorif kde:kde_color = kde_kws.pop("color", color)kdeplot(a, vertical=vertical, ax=ax, color=kde_color, **kde_kws)if kde_color != color:kde_kws["color"] = kde_colorif rug:rug_color = rug_kws.pop("color", color)axis = "y" if vertical else "x"rugplot(a, axis=axis, ax=ax, color=rug_color, **rug_kws)if rug_color != color:rug_kws["color"] = rug_colorif fit is not None:def pdf(x):return fit.pdf(x, *params)fit_color = fit_kws.pop("color", "#282828")gridsize = fit_kws.pop("gridsize", 200)cut = fit_kws.pop("cut", 3)clip = fit_kws.pop("clip", (-np.inf, np.inf))bw = stats.gaussian_kde(a).scotts_factor() * a.std(ddof=1)x = _kde_support(a, bw, gridsize, cut, clip)params = fit.fit(a)y = pdf(x)if vertical:x, y = y, xax.plot(x, y, color=fit_color, **fit_kws)if fit_color != "#282828":fit_kws["color"] = fit_colorif label_ax:if vertical:ax.set_ylabel(axlabel)else:ax.set_xlabel(axlabel)return ax

成功解决TypeError: distplot() got an unexpected keyword argument ‘y‘相关推荐

  1. 成功解决TypeError: read_excel() got an unexpected keyword argument ‘parse_cols or ‘sheetname‘

    成功解决TypeError: read_excel() got an unexpected keyword argument 'parse_cols' TypeError: read_excel() ...

  2. 成功解决TypeError: take() got an unexpected keyword argument ‘fill_value‘

    成功解决TypeError: take() got an unexpected keyword argument 'fill_value' 目录 解决问题 解决思路 解决方法 解决问题 Traceba ...

  3. 成功解决TypeError: __init__() got an unexpected keyword argument 'indices'

    成功解决TypeError: __init__() got an unexpected keyword argument 'indices' 目录 解决问题 解决思路 解决方法 解决问题 TypeEr ...

  4. 成功解决TypeError: __init__() got an unexpected keyword argument 'n_iterations'

    成功解决TypeError: __init__() got an unexpected keyword argument 'n_iterations' 目录 解决问题 解决思路 解决方法 解决问题 T ...

  5. 成功解决TypeError: map() got an unexpected keyword argument 'num_threads'

    成功解决TypeError: map() got an unexpected keyword argument 'num_threads' 目录 解决问题 解决思路 解决方法 解决问题 TypeErr ...

  6. 成功解决TypeError: __init__() got an unexpected keyword argument 'serialized_options'

    成功解决TypeError: __init__() got an unexpected keyword argument 'serialized_options' 目录 解决问题 解决思路 解决方法 ...

  7. 成功解决TypeError: concat() got an unexpected keyword argument ‘join_axes‘

    成功解决TypeError: concat() got an unexpected keyword argument 'join_axes' 目录 解决问题 解决思路 解决方法 解决问题 TypeEr ...

  8. 解决typeError: init() got an unexpected keyword argument ‘serialized_options’

    解决typeError: init() got an unexpected keyword argument 'serialized_options' 问题描述:运行python文件时,手贱捣鼓了一下 ...

  9. 成功解决TypeError: ‘encoding’ is an invalid keyword argument for this function

    成功解决TypeError: 'encoding' is an invalid keyword argument for this function 目录 解决问题 解决思路 解决方法 解决问题 Ty ...

  10. 已解决TypeError: __init__() got an unexpected keyword argument ‘n_iterations‘

    已解决TypeError: init() got an unexpected keyword argument 'n_iterations' 文章目录 报错问题 解决方法 PS 报错问题 之前在工作中 ...

最新文章

  1. Python进阶1——一摞纸牌
  2. vue 圆形百分比进度条_vue实用组件——圆环百分比进度条
  3. 自动化监控--zabbix-get安装使用详解
  4. C#的循环语句(一)
  5. ubuntu下git服务器搭建过程
  6. CF917B MADMAX
  7. python ctypes 回调函数_如何用Python中的ctypes创建回调函数?
  8. 可以飞的电动汽车,波音与保时捷要合作开发了
  9. SCPPO(七):安全检测及分析神器—AppScan使用教程
  10. 十三五规划中中国制造2025
  11. TCP/IP协议号大全
  12. 如何使用BitBar将几乎所有信息添加到Mac的菜单栏中
  13. jabber服务器搭建
  14. word中图片为嵌入式格式时显示不全_电脑中Word图片显示不全的六种处理方法
  15. PDF文档翻译(英文翻译为中文)
  16. Python 读取/处理 s2k/$2k 文本文件
  17. 量化基金 获取每日基金排行数据和其对应持仓情况;统计持股股票排行
  18. 精益求精, ePub 电子书制作手记
  19. 摸鱼 | 远程控制实验室服务器(不在同一局域网)
  20. 宁德时代与戴姆勒卡车股份公司扩大全球合作伙伴关系

热门文章

  1. matlab三次方程求根,如何用matlab求一元三次方程的最小正根?
  2. 二元一次方程组计算机题,2元一次方程组(二元一次方程组计算题带答案)
  3. linux 如何把文件夹压缩文件,如何在Ubuntu桌面中将文件/文件夹压缩为.zip,tar.xz和7z格式...
  4. Cyclone IV E系列介绍
  5. 计算机除氧化的方法,内存条氧化了的解决方法
  6. python计算定积分_python 求定积分和不定积分示例
  7. 开源工具TestDisk数据恢复方法
  8. 工行纸黄金软件测试,只需一万元,工行刷星7级下卡2万的方法
  9. MAC 用了Mounty之后移动硬盘文件夹、文件消失
  10. 使用keycloak自定义SPI接入外部用户登录