I'm trying to create a simple bar graph with some data (hard coded here, but I'll be reading it in from a file at some point). So far, I'm able to get the bar graph, but I would like the attribute "Feature Name" to come under each bar. Right now, I'm only getting numbers 1 through 16. What can I do to make each feature under each bar?
My code:
import matplotlib.pyplot as plt
import numpy as np
import mpld3
fig, ax = plt.subplots()
N = 17
feature_name = ('AccountLength','Intlact','Vmailact','Vmailnumber','day minutes','day calls','day charge','evening minutes','evening calls','evening charge','night minutes','night calls','night charge','intl minutes','intl calls','intl charge','cust calls')
importance = (0.0304,0.0835,0.0222,0.0301,0.1434,0.0315,0.1354,0.0677,0.0268,0.0669,0.0386,0.0286,0.0371,0.0417,0.0521,0.0434,0.1197)
ind = np.arange(N)
width = 0.20
rects = ax.bar(ind, importance, width, color = 'r')
ax.grid(color='white', linestyle='solid')
ax.set_title("Why are my customers churning?", size=20)
ax.set_ylabel('Importance in percentage')
ax.set_xlabel('Feature Name')
ax.set_xticklabels( (feature_name) )
labels = (feature_name)
tooltip = mpld3.plugins.PointLabelTooltip(rects, labels=labels)
mpld3.plugins.connect(fig, tooltip)
mpld3.show()
Edit: turns out that if I use plt.show(), I can see ticklabels, but when I try to do the same in mpld3, it doesn't work. Also wondering why the tooltip doesn't show up.