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
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.
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.
ANS-> The y-axis in a density plot is the probability density function for the kernel density estimation.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With