Skip to content

Instantly share code, notes, and snippets.

@SKaplanOfficial
Last active January 18, 2023 22:01
Show Gist options
  • Save SKaplanOfficial/4871ea0bb2dc245d7775b7fc390a22a5 to your computer and use it in GitHub Desktop.
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
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