%matplotlib inline import pylab as pl import matplotlib as mpl from pylab import cos, sin def plot_circle(): circle = mpl.patches.Circle((0, 0), radius=1, fill=False) a = pl.gca() a.add_patch(circle) pl.xlim(-1.1, 1.1) pl.ylim(-1.1, 1.1) a.set_aspect('equal') a.set_axis_off() def annotate_and_label(): note_labels = ['1', 'b2', '2', 'b3', '3', '4', 'b5', '5', 'b6', '6', 'b7', '7'] for i in range(12): theta = pl.pi/2 - 2 * pl.pi / 12. * i x, y = cos(theta), sin(theta) #pl.plot((0, x), (0, y)) pl.plot((x), (y), 'ok', ) pl.annotate(note_labels[i], (x, y), (1.15 * x, 1.15 * y)) def plot_note(note, with_line=False): note = note % 12 theta = pl.pi/2 - 2 * pl.pi / 12. * note x, y = cos(theta), sin(theta) # plot line before point if with_line: pl.plot((0, x), (0, y), '-k') # plot point pl.plot((x), (y), 'o', markeredgecolor='blue', markeredgewidth=10) plot_circle() annotate_and_label() plot_note(2) plot_note(7, with_line=True) # setup diagram plot_circle() annotate_and_label() # plot chord major7_chord = [0, 4, 7, 11] for note in major7_chord: plot_note(note, with_line=True) pl.figure(figsize=(10, 10)) for i in range(4): pl.subplot(2, 2, i + 1) plot_circle() annotate_and_label() chord = map(lambda note: (note - major7_chord[i]) % 12, major7_chord) for note in chord: plot_note(note, with_line=True) pl.title('Inversion %s' % (i + 1)) #pl.tight_layout(pad=0.8)