In this course, you've learned how to create many different chart types. Now, you'll organize your knowledge, before learning some quick commands that you can use to change the style of your charts.

What have you learned?

https://storage.googleapis.com/kaggle-media/learn/images/LPWH19I.png

Since it's not always easy to decide how to best tell the story behind your data, we've broken the chart types into three broad categories to help with this.

Changing styles with seaborn

All of the commands have provided a nice, default style to each of the plots. However, you may find it useful to customize how your plots look, and thankfully, this can be accomplished by just adding one more line of code!

As always, we need to begin by setting up the coding environment.

import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
import seaborn as sns
print("Setup Complete")

We'll work with the same code that we used to create a line chart in a previous tutorial. The code below loads the dataset and creates the chart.

# Path of the file to read
spotify_filepath = "../input/spotify.csv"

# Read the file into a variable spotify_data
spotify_data = pd.read_csv(spotify_filepath, index_col="Date", parse_dates=True)

# Line chart 
plt.figure(figsize=(12,6))
sns.lineplot(data=spotify_data)
<AxesSubplot:xlabel='Date'>

https://www.kaggleusercontent.com/kf/126573737/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..uJg7_ju7oG7gOk7nB-n14Q.7qDrygce_51EVyYet3Wwqfi2vtgB1qAakPe_zxLW5xjIWLYEjbQyPFZRwF2TZPda8bA6RY707Ni8oOwNaGGGtKymzGOvgdjCvClcrlvBauVvu1FBl0g74zbRVUmxJayfyiZLY3dgstJPBp5_cl0igwei__GDhdnB8ReH5JoIToZGx_TLntHDhmLAsNTsEtLdx1TGL34C1x7Os8WlTHrC4-pwBQPxFdxUpW1Wj-1APSvr7Yie5T6fsFzqINYvwEz4_8nkaOo8rQCsEYIYO251HYpkmtj5PtvB_Xruw2MaWiDTWkVfKic0M2iLqPggB4fKuYEJk6O32xyA8OcxSQnsDlr82SpxYwa-Ybk9MQe48BhB44jUXlrQaZ1hwlbrJI7WivsDI5yteDruMprHGt5tSlxH_Yd8qtIXQ5ww7CeS3W-5wHatUEX30V5vwlQSgqtcsy6sluLKbLhsSl30CFYaKUwSNW5ls8EYhugBHe0jZkiBs8TRp8XAndJ4F991noAH_5XuyGJx9t5jBXKawvqf4WoFWsddjoh4tzUgJqPiM4Xg3LlvLHM7GgLFKmqolho0uLMMOcrl_3Vm17SLWTqM5MLCS_ker9OykOb2Ta92WLKp6jp75ugujqYV6drKDmk0pMd-wl32bZjoeF55JmAzvBUfyJasowOxKUZP8UApq76fUmiY9g2C58QoamK1uUZH.B0lWAc2PZZQDkuEjvN1xZg/__results___files/__results___4_1.png

We can quickly change the style of the figure to a different theme with only a single line of code.

# Change the style of the figure to the "dark" theme
sns.set_style("dark")

# Line chart 
plt.figure(figsize=(12,6))
sns.lineplot(data=spotify_data)
<AxesSubplot:xlabel='Date'>

https://www.kaggleusercontent.com/kf/126573737/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..uJg7_ju7oG7gOk7nB-n14Q.7qDrygce_51EVyYet3Wwqfi2vtgB1qAakPe_zxLW5xjIWLYEjbQyPFZRwF2TZPda8bA6RY707Ni8oOwNaGGGtKymzGOvgdjCvClcrlvBauVvu1FBl0g74zbRVUmxJayfyiZLY3dgstJPBp5_cl0igwei__GDhdnB8ReH5JoIToZGx_TLntHDhmLAsNTsEtLdx1TGL34C1x7Os8WlTHrC4-pwBQPxFdxUpW1Wj-1APSvr7Yie5T6fsFzqINYvwEz4_8nkaOo8rQCsEYIYO251HYpkmtj5PtvB_Xruw2MaWiDTWkVfKic0M2iLqPggB4fKuYEJk6O32xyA8OcxSQnsDlr82SpxYwa-Ybk9MQe48BhB44jUXlrQaZ1hwlbrJI7WivsDI5yteDruMprHGt5tSlxH_Yd8qtIXQ5ww7CeS3W-5wHatUEX30V5vwlQSgqtcsy6sluLKbLhsSl30CFYaKUwSNW5ls8EYhugBHe0jZkiBs8TRp8XAndJ4F991noAH_5XuyGJx9t5jBXKawvqf4WoFWsddjoh4tzUgJqPiM4Xg3LlvLHM7GgLFKmqolho0uLMMOcrl_3Vm17SLWTqM5MLCS_ker9OykOb2Ta92WLKp6jp75ugujqYV6drKDmk0pMd-wl32bZjoeF55JmAzvBUfyJasowOxKUZP8UApq76fUmiY9g2C58QoamK1uUZH.B0lWAc2PZZQDkuEjvN1xZg/__results___files/__results___6_1.png