In [1]:
%matplotlib inline 

import pandas as pd
import matplotlib.pyplot as plt

In [2]:
df = pd.read_csv('../data/data.csv', index_col='Year')

In [3]:
df.plot(
    kind='area',                 # type of plot
    figsize=(20, 10),          # 2:1 ratio. Is there a standard ratio for plots?
    ylim=(0,100),               # Don't want extra space
    colormap='terrain',    # Bit lazy using standard color scheme,
                                           # and Folk and Funk don't have enough
                                           # contrast between each other
    xticks=([1951] +
                  list(range(1955, 2015, 5)) +
                  [2016]),              # Show beginning/ending + year divisible by 5
    rot=-10,                         # Bit of rotation makes them look better I think
    fontsize=18,                  # For axis ticks
    linewidth=0,                  # Otherwise even when a quantity is 0, you still get a bit of display
                                            # e.g. it would show there's a bit of electronic music before it was
                                            # invented
    legend=False               # I think legend is unnecessary cause it requires the viewer
                                            # to go between colours and legend. It's a bit less formal
                                            # but it targets casual environements.
)

# Graph title
plt.title('Billboard Hot 100 by Genre (1951 - 2016)', fontsize=22)

# Labels
plt.ylabel('Proportions', fontsize=20)
plt.xlabel('Year', fontsize=20)

# I don't think the y ticks are very useful,
# so I'll keep only first and last
plt.yticks((0, 100))
    
# Creat font for overlay 
font = {
    'family': 'sans-serif',
    'weight': 'normal',
    'size': 25,
    'backgroundcolor': 'black',
    'color': 'white',
}

# Manually position text
plt.text(1971, 20, 'Rock', fontdict=font)
plt.text(1966, 53, 'Pop', fontdict=font)
plt.text(1994, 78, 'Electronic', fontdict=font)
plt.text(2001, 50, 'Hip Hop', fontdict=font)
plt.text(1970, 80, 'Funk/Soul', fontdict=font)
plt.text(1952, 92, 'Jazz', fontdict=font)
plt.text(1957, 88, 'Folk/Country', fontdict=font)
plt.plot()
plt.savefig('../figures/visualisation.png', format='png')