0

I'm trying to create a density plot without histogram but it returns the error--- AttributeError: 'Rectangle' object has no property 'hist' How can I solve this error? FYI: y_train and yhat_train is 1D array

plt.figure(figsize=(16, 8))

ax1 = sns.displot(y_train, hist=False ,color='r', label='Actual value')
ax2 = sns.displot(yhat_train, hist=False ,color='b', label='Predicted value', ax=ax1)

plt.show()

enter image description here

  • 2
    Note that `displot` is a [figure-level function](https://seaborn.pydata.org/tutorial/function_overview.html#figure-level-vs-axes-level-functions), which creates a new figure, possibly with subplots. You should use it without `plt.figure`. Also, `displot` doesn't accept `ax=` as parameter nor returns an `ax` (it returns a `FacetGrid`). The old axes-level `distplot` has been deprecated. You can either use `histplot` or `kdeplot` as an improved replacement. You can refer to the online docs of each function, for a concise explanation of the parameters. – JohanC Sep 19 '21 at 08:47

0 Answers0