Wednesday, June 16, 2021

【PYTHON】Violin Plots

 sns.histplot(x=df['Minutes'], kde=True)


# save figure for book

f = plt.figure(figsize=(5.5, 5.5))  # this changes the size of the image -- more on this is chapter 5

f.patch.set_facecolor('w')  # sets background color behind axis labels

sns.histplot(x=df['Minutes'], kde=True)

plt.tight_layout()  # auto-adjust margins

plt.savefig('B17030_05_04.png', dpi=300)


sns.violinplot(data=df, x='Minutes')


# save figure for book

f = plt.figure(figsize=(5.5, 5.5))  # this changes the size of the image -- more on this is chapter 5

f.patch.set_facecolor('w')  # sets background color behind axis labels

sns.violinplot(data=df, x='Minutes')

plt.tight_layout()  # auto-adjust margins

plt.savefig('B17030_05_05.png', dpi=300)


top_5_genres = df['Genre'].value_counts().index[:5]

top_5_data = data=df[df['Genre'].isin(top_5_genres)]


sns.violinplot(data=top_5_data, x='Minutes', y='Genre')


# save figure for book

f = plt.figure(figsize=(5.5, 5.5))  # this changes the size of the image -- more on this is chapter 5

f.patch.set_facecolor('w')  # sets background color behind axis labels

sns.violinplot(data=top_5_data, x='Minutes', y='Genre')

plt.tight_layout()  # auto-adjust margins

plt.savefig('B17030_05_06.png', dpi=300)

No comments:

Post a Comment

End of Summer Sale ☀️😎

20% OFF Inside!🤯 ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏...