def barchart_ax(discrete_df, title='各个特征取值数量统计', xlabel='特征名称', ylabel='特征的不同取值量', background_color= "#EAEAF2", Batch1_color = "#25AFF3"):
feature_values = []
x_text = []
for c in discrete_df.columns[1:]:
x_text.append(c)
ct = discrete_df[c].duplicated(keep ='first')
feature_values.append(len(ct[ct==False]))
batch1=feature_values
pylab.rcParams['figure.figsize'] = (19.0, 10.0)
plt.rcParams['font.sans-serif'] = ['KaiTi']
matplotlib.rcParams['axes.unicode_minus'] = False
x = np.arange(len(x_text))
width = 0.66
fig, ax = plt.subplots()
rects = ax.bar(x - width/2, batch1, width, color = Batch1_color)
ax.patch.set_facecolor(background_color)
ax.set_title(title, fontsize=26)
ax.set_xlabel(xlabel, fontsize=22)
ax.set_ylabel(ylabel, fontsize=22)
ax.set_xticks(x)
ax.set_xticklabels(x_text, fontsize=22)
for rect in rects:
height = rect.get_height()
ax.annotate('{}'.format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0,3),
textcoords="offset points",
ha='center', va='bottom')
plt.grid(linestyle = "dotted",color = "g")
plt.xticks(rotation=89)
fig.tight_layout()
plt.show()