In this Seaborn tutorial, you will learn how to change the Seaborn theme. Seaborn provides a built-in function sns.set_theme() for this task.
# import required modules import seaborn as sns import matplotlib.pyplot as plt # load the dataset var = sns.load_dataset('iris') # set the theme sns.set_theme(style = 'darkgrid') # create a box plot using seaborn sns.boxplot(x = 'species', y = 'sepal_length', data = var) # set the title of the plot plt.title('Box Plot') # save the plot plt.savefig('boxplot_theme.png') # show the plot plt.show()
Output:
Free resources to learn advanced skills: AiHints and CodeAllow