I am writing code to analyse the musical taste of me and 3 of my friends in python. Using spotipy, we extracted the song info of our '2020 most played' playlists in spotify. The data of these 4 playlists are stored in a dataframe.
First, i defined the data out of the dataframe that i want to use for the histograms.
user1_tempo = trainingData[trainingData['user'] == 'user1']['tempo']
user2_tempo = trainingData[trainingData['user'] == 'user2']['tempo']
user3_tempo = trainingData[trainingData['user'] == 'user3']['tempo']
user4_tempo = trainingData[trainingData['user'] == 'user4']['tempo']
After that, I made 4 histograms on top of each other so I can compare the results.
plt.title("Song Tempo per person")
user1_tempo.hist(alpha=0.5, bins=30, label='Me')
user2_tempo.hist(alpha=0.5, bins=30, label='Friend 1')
user3_tempo.hist(alpha=0.5, bins=30, label='Friend 2')
user4_tempo.hist(alpha=0.5, bins=30, label='Friend 3')
plt.xticks(np.arange(0,220, 10))
plt.legend(loc='upper right')
Of course, 4 histograms into each other look very messy. It looks like this
Is there a way to temporary disable some of the plots with checkboxes?
Aucun commentaire:
Enregistrer un commentaire