I wrote some code in Jupyter notebook, and when I ran it there, the graphs looked nice. But when I uploaded it to kaggle, suddenly the graphs don’t look right. the legend has too many values and isn’t in the right place, and the bars look skinny and not all the data is being shown. I don’t know why it would change between the two platforms like that.
Jupyter Notebook Graph
Kaggle Graph
This is the code I have for the graph:
# Calculate the threshold for the top 10% of 'Spotify Streams'
streams_threshold = song_data['Spotify Streams'].quantile(0.90)
# Filter the dataset to include only rows where 'Spotify Streams' is above the threshold
top_streams_data = song_data[song_data['Spotify Streams'] >= streams_threshold]
# Calculate the threshold for the top 10% of 'Spotify Playlist Count' within the filtered dataset
playlist_threshold = top_streams_data['Spotify Playlist Count'].quantile(0.90)
# Further filter the data to include only rows where 'Spotify Playlist Count' is above this new threshold
top_data = top_streams_data[top_streams_data['Spotify Playlist Count'] >= playlist_threshold]
# Create a bar plot using Seaborn
plt.figure(figsize=(10, 6))
sns.barplot(x='Spotify Streams', y='Spotify Playlist Count', data=top_data, hue='Spotify Playlist Count', palette='Blues')
# Adding labels and title
plt.xlabel('Spotify Streams')
plt.ylabel('Spotify Playlist Count')
plt.title('Top 10% Spotify Streams Versus Playlist Count')
plt.xticks(rotation = 90)
# Show the plot
plt.show()type here
I don’t know why it looks different now. I tried moving the legend with plt.legend which worked, but it still has all those other values I didn’t want in there. And I tried making the bars of the graph wider, which I can do, but it doesn’t solve the problem of the missing bars.
Sara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.