splotify.plots package
Submodules
splotify.plots.audiofeatures module
AudioFeaturesPlot class.
This module contains the AudioFeaturesPlot class that plots the audio features of your selected tracks.
- class splotify.plots.audiofeatures.AudioFeaturesPlot(sp, data, features)[source]
Bases:
objectObject to plot the audio features of a group of tracks.
Supports 2D and 3D scatter plots, histograms, and box plots. The supported features are:
“acousticness”, “danceability”, “duration_ms”, “energy”, “instrumentalness”, “key”, “liveness”, “loudness”, “mode”, “speechiness”, “tempo”, “time_signature”, “valence”
These features are explained further in the Spotify Web API documentation.
- Parameters:
sp (splotify.spotifyapi.SpotifyApi) – A SpotifyApi instance.
data (splotify.data.Data) – A Data instance.
features (
listofstr) – The list of audio features that you want to plot. If len(features) > 3, only the first 3 features in the list will be selected.
- box_plot(feature, groupby=None)[source]
Plots the tracks in a box plot by the selected audio feature.
Setting the groupby parameter will plot each resulting group as a separate box plot.
- Parameters:
feature (str) – The audio feature you want to plot.
groupby (
str, optional) – What to group the tracks by. Currently only supports ‘artist’ and ‘album’. Defaults to ‘None’.
- histogram(feature, color=None)[source]
Plots the tracks in a histogram by the selected audio feature.
- Parameters:
feature (str) – The audio feature you want to plot.
color (
str, optional) – What the color of the points on the plot represent. Currently only supports ‘artist’ and ‘album’. Defaults to ‘None’.
- scatter_plot_2d(color=None)[source]
Plots the tracks in a 2D scatter plot by the first 2 selected audio features.
- Parameters:
color (
str, optional) – What the color of the points on the plot represent. Currently only supports ‘artist’ and ‘album’. Defaults to ‘None’.
- scatter_plot_2d_average(groupby='album')[source]
Plots the averages of tracks in a 2D scatter plot by the first 2 selected audio features.
Groups the tracks based on the groupby parameter, computes the averages of each audio feature for each group, and plots the averages.
- Parameters:
groupby (
str) – What to group the tracks by. Currently only supports ‘artist’ and ‘album’. Defaults to ‘album’.
- scatter_plot_3d(color=None)[source]
Plots the tracks in a 3D scatter plot by the first 3 selected audio features.
- Parameters:
color (
str, optional) – What the color of the points on the plot represent. Currently only supports ‘artist’ and ‘album’. Defaults to ‘None’.
- scatter_plot_3d_average(groupby='album')[source]
Plots the averages of tracks in a 3D scatter plot by the first 3 selected audio features.
Groups the tracks based on the groupby parameter, computes the averages of each audio feature for each group, and plots the averages.
- Parameters:
groupby (
str) – What to group the tracks by. Currently only supports ‘artist’ and ‘album’. Defaults to ‘album’.
splotify.plots.category module
CategoryPlot class.
This module contains the CategoryPlot class that plots the categories of your selected tracks.
- class splotify.plots.category.CategoryPlot(data)[source]
Bases:
objectObject to plot the categories of a group of tracks.
Supports bar charts and pie charts. Good for looking at the composition of playlists (i.e. how many songs are from each album/artist).
- Parameters:
data (splotify.data.Data) – A Data instance.
- bar_chart(groupby='album')[source]
Plots the grouped tracks in a bar chart.
Groups the tracks based on the groupby parameter, counts the number of tracks of each group, and plots the counts.
- Parameters:
groupby (
str) – What to group the tracks by. Currently only supports ‘artist’ and ‘album’. Defaults to ‘album’.
- pie_chart(groupby='album')[source]
Plots the grouped tracks in a pie chart.
Groups the tracks based on the groupby parameter, counts the number of tracks of each group, and plots the counts.
- Parameters:
groupby (
str) – What to group the tracks by. Currently only supports ‘artist’ and ‘album’. Defaults to ‘album’.
splotify.plots.popularity module
PopularityPlot class.
This module contains the PopularityPlot class that plots the popularity of your selected tracks.
- class splotify.plots.popularity.PopularityPlot(sp, data)[source]
Bases:
objectObject to plot the popularity of a group of tracks.
Supports bar charts. Based on Spotify’s popularity variable for tracks and albums.
- Parameters:
sp (splotify.spotifyapi.SpotifyApi) – A SpotifyApi instance.
data (splotify.data.Data) – A Data instance.