def plot_br_chart(self,column):
if type(self.woe_dicts[column].items()[0][0]) == str:
woe_lists = sorted(self.woe_dicts[column].items(), key = self.sort_dict)
else:
woe_lists = sorted(self.woe_dicts[column].items(),key = lambda item:item[0])
sns.set_style(rc={"axes.facecolor": "#EAEAF2",
"axes.edgecolor": "#EAEAF2",
"axes.linewidth": 1,
"grid.color": "white",})
tick_label = [i[0] for i in woe_lists]
counts = [i[1][1] for i in woe_lists]
br_data = [i[1][2] for i in woe_lists]
x = range(len(counts))
fig, ax1 = plt.subplots(figsize=(12,8))
my_palette = sns.color_palette(n_colors=100)
sns.barplot(x,counts,ax=ax1,palette=sns.husl_palette(n_colors=20,l=.7))
plt.xticks(x,tick_label,rotation = 30,fontsize=12)
plt.title(column,fontsize=18)
ax1.set_ylabel('count',fontsize=15)
ax1.tick_params('y',direction='in',length=6, width=0.5, labelsize=12)
#ax1.bar(x,counts,tick_label = tick_label,color = 'y',align = 'center')
#ax1.bar(x,counts,color = 'y',align = 'center')
ax2 = ax1.twinx()
ax2.plot(x,br_data,color='black')
ax2.set_ylabel('bad rate',fontsize=15)
ax2.tick_params('y',direction='in',length=6, width=0.5, labelsize=12)
plot_margin = 0.25
x0, x1, y0, y1 = ax1.axis()
ax1.axis((x0 - plot_margin,
x1 + plot_margin,
y0 - 0,
y1 * 1.1))
plt.show()
information_value.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录