Last active
January 18, 2023 22:01
-
-
Save SKaplanOfficial/4871ea0bb2dc245d7775b7fc390a22a5 to your computer and use it in GitHub Desktop.
PyXA script to generate a histogram of track genres in your Music.app library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import PyXA # Version 0.2.0 | |
app = PyXA.Application("Music") | |
genre_data = Counter(app.tracks().genre()).most_common() | |
labels, values = zip(*genre_data) | |
indexes = np.arange(len(labels)) | |
plt.bar(indexes, values, 1) | |
plt.xticks(indexes, labels, rotation='vertical') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment