Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: distplot() got an unexpected keyword argument 'x' (or 'hue')

I get the error when I try and plot this-

sns.distplot(X_train, x='Age')                   #Age is a feature in X_train

I get a similar error when I try and add the hue parameter in there

sns.distplot(X_train['Age'], hue=y_train)

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

What am I doing wrong? Here is where I am trying out the code from-

https://seaborn.pydata.org/tutorial/distributions.html

like image 607
callmeanythingyouwant Avatar asked Sep 13 '20 18:09

callmeanythingyouwant


People also ask

What is Distplot in Python?

Python Seaborn module contains various functions to plot the data and depict the data variations. The seaborn. distplot() function is used to plot the distplot. The distplot represents the univariate distribution of data i.e. data distribution of a variable against the density distribution.

How do I change the color of my Distplot in Seaborn?

By dfault, Seaborn's distplot() makes the histogram filling the bars in blue. We can manually change the histogram color using the color argument inside distplot() function. In this example, we have used the argument color=”purple” to make purple histogram as shown below.

What is the y axis in Distplot?

ANS-> The y-axis in a density plot is the probability density function for the kernel density estimation.

What is Hist_kws?

hist_kws is an optional argument in distplot which takes only values in a dictionary. You can use this to set linewidth, edgecolor etc. Example for your ref. Follow this answer to receive notifications. answered May 30, 2021 at 16:19.


1 Answers

If someone comes across this same issue, here's what lead to the confusion. Thanks @user2864740

sns.distplot() is deprecated.

sns.displot() is the new function with hue and x parameters.

If you get this error, update your seaborn version. In cmd -

pip install seaborn --upgrade

From inside a notebook, add an ! before pip

like image 121
callmeanythingyouwant Avatar answered Sep 18 '22 07:09

callmeanythingyouwant