Introduction

In this tutorial, we want to change the style of plots. In order to do this, we use the set_style() function of Seaborn.

Overview of Figure Styles

Seaborn offers several predefined styles for figures. With the set_style() function the figure style can be set.

The following styles are available:

  • whitegrid
  • white
  • darkgrid
  • dark
  • ticks

Let's take a closer look at each style. In order to do this, we look at different styles for our violin plot from the previous post.Haven't you seen the post yet? Then make sure you check it out first.

Whitegrid

Let's have a look at the figure style "whitegrid".

#figure style
sns.set_style('whitegrid')
fig, ax = plt.subplots(figsize=(8, 4))

#plot violins
sns.violinplot(x='species', y='body_mass_g', data=penguins_df)

plt.show()

White

Let's have a look at the figure style "white".

#figure style
sns.set_style('white')
fig, ax = plt.subplots(figsize=(8, 4))

#plot violins
sns.violinplot(x='species', y='body_mass_g', data=penguins_df)

plt.show()

Darkgrid

Let's have a look at the figure style "darkgrid".

#figure style
sns.set_style('darkgrid')
fig, ax = plt.subplots(figsize=(8, 4))

#plot violins
sns.violinplot(x='species', y='body_mass_g', data=penguins_df)

plt.show()

Dark

Let's have a look at the figure style "dark".

#figure style
sns.set_style('dark')
fig, ax = plt.subplots(figsize=(8, 4))

#plot violins
sns.violinplot(x='species', y='body_mass_g', data=penguins_df)

plt.show()

Ticks

Let's have a look at the figure style "ticks".

#figure style
sns.set_style('ticks')
fig, ax = plt.subplots(figsize=(8, 4))

#plot violins
sns.violinplot(x='species', y='body_mass_g', data=penguins_df)

plt.show()

Conclusion

Congratulations! Now you are one step closer to become an AI Expert. You have seen that it is very easy to change the style of plots. We can simply use the set_style()  function of Seaborn. Try it yourself!

Instagram

Also check out our Instagram page. We appreciate your like or comment. Feel free to share this post with your friends.