In [56]:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd
pd.set_option('display.width', 500)
pd.set_option('display.max_columns', 100)
pd.set_option('display.notebook_repr_html', True)
import seaborn as sns
sns.set_style("whitegrid")
sns.set_context("poster")

In [108]:
N = 5
GAP = 1.5
indices = np.arange(N)
colors = sns.color_palette("RdBu_r", 5)
width = 1. / (N + GAP)
hfont = {'family':'Myriad Pro', 'style': 'normal'}
mpl.rc('font', **hfont)
fig, ax = plt.subplots(figsize=(15,8))
lg_vals = [58.29, 56.09, 67.06, 8.22, 36.33]
lg_bar = ax.bar(indices, lg_vals, width, color=colors[0], label='Multinomial Logistic Regression')
nb_vals = [48.19, 50.43, 62.66, 34.73, 31.65]
nb_bar = ax.bar(indices + width, nb_vals, width, color=colors[1], label='Multinomial Naive Bayes')
rf_vals = [63.71, 59.72, 69.73, 47.22, 46.81]
rf_bar = ax.bar(indices + width * 2, rf_vals, width, color=colors[2], label='Random Forests')
mccf_train_vals = [28.5, 49.5, 63.9, 22.6, 20.3]
mccf_train_bar = ax.bar(indices + width * 3, mccf_train_vals, width, color=colors[3], label='MCCF - Training')
mccf_test_vals = [28.5, 49.5, 63.9, 22.6, 20.3]
mccf_test_bar = ax.bar(indices + width * 4, mccf_test_vals, width, color=colors[4], label='MCCF - Test')

# Ticks, labels, axes, legend
ax.set_xticks(indices + width * N / 2)
ax.set_xticklabels(('Root', 'Base', 'Inversion', 'Alto', 'Tenor'))
ax.set_xlabel("Subtasks")
ax.set_ylabel("Test Accuracy (%)")
ax.set_xlim([-0.3, 5.3])
ax.set_ylim([0, 100])
hfont['style'] = 'italic'
ax.legend(loc='upper right', prop=hfont)


def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width()/2., height + 2,
                '%.1f' % height,
                ha='center', va='bottom', size='large')

# Label bars
autolabel(lg_bar)
autolabel(nb_bar)
autolabel(rf_bar)
autolabel(mccf_train_bar)
autolabel(mccf_test_bar)

plt.savefig('subtasks.png', dpi=300)
plt.show()



In [ ]:
import matplotlib.font_manager as font_manager

for font in font_manager.findSystemFonts():
    prop = font_manager.FontProperties(fname=font)
    try:
        print prop.get_name()
    except:
        print "N/A"