0

as Seaborn warned to prefer 'displot' to future deprecated 'distplot', I'm trying to change old codes. Unfortunately I find a bit hard finding corresponding parameters for several inputs. Just an example: below I start with the old 'distplot' code working:

c=np.random.normal(5,2,100)
sns.distplot(c,hist=True,kde=True,color='g',kde_kws={'color':'b','lw':2,'label':'Kde'},hist_kws={'color':'purple','alpha':0.8,
            'histtype':'bar','edgecolor':'k'})

Now, I want to show the same result with 'displot' but I don't know how to put 'alpha' for histogram as well as all the 'hist_kws' stuff. Below how I started:

sns.displot(data=c,kind='hist',kde=True,facecolor='purple',edgecolor='k',color='b',
            alpha=1,line_kws={'lw':2})

I'm looking for a better documentation but I didn't have luck so far

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Polar
  • 147
  • 1
  • 11
  • See also https://stackoverflow.com/questions/67638590/emulating-deprecated-seaborn-distplots – JohanC May 11 '22 at 19:46
  • Something like `g = sns.displot(c, kde=True, line_kws={'lw': 2, 'label': 'Kde'}, color='purple', alpha=0.8, edgecolor='k')` followed by `g.ax.lines[0].set_color('b')` could work. Note that for a single subplot `sns.histplot` is the most similar to `sns.distplot`. Changing the color of the kde line isn't straightforward yet. See also [How to modify the kernel density estimate line in a sns.histplot](https://stackoverflow.com/questions/69524514/how-to-modify-the-kernel-density-estimate-line-in-a-sns-histplot) – JohanC May 11 '22 at 19:59

0 Answers0