import matplotlib.patches as patches
df = data_new.groupby('qcut_daily_order_value').size().reset_index(name='counts')
X = ['(-3, 0]', '(0, 3]', '(3, 6]', '(6, 9]', '(9, 12]', '(12, 15]']
fig, ax = plt.subplots(figsize=(15,8)
,facecolor='white'
,dpi=80)
ax.vlines(x=df.index
, ymin=0
,ymax=df.counts
,color='firebrick'
,alpha=1
,linewidth=30)
for i,count in enumerate(df.counts):
ax.text(i,count+50000, '{:.2f}% ({})' .format(((count/np.sum(df.counts))*100),count) ,
horizontalalignment='center')
ax.set_title('test',fontdict={'size':22})
ax.set_ylabel('test',fontdict={'size':16})
ax.set(ylabel='y',ylim=(0,4000000))
plt.xticks(df.index
, df.qcut_daily_order_value.astype(str)
,rotation=50
,horizontalalignment='right'
,fontsize=12)
df = data_new.groupby('ccccccccc').size().reset_index(name='counts')
fig, ax = plt.subplots(figsize=(12, 10), subplot_kw=dict(aspect="equal"), dpi= 80)
data = df['counts']
categories = df['ccccccccc']
explode = np.zeros(df.shape[0])
def func(pct, allvals):
absolute = int(pct/100.*np.sum(allvals))
return "{:.1f}% ({:d} )".format(pct, absolute)
wedges, texts, autotexts = ax.pie(data,
autopct=lambda pct: func(pct, data),
textprops=dict(color="w"),
colors=plt.cm.Dark2.colors,
startangle=200
,explode=explode)
ax.legend(wedges, categories, title="bins", loc="center left", bbox_to_anchor=(1, 0, 0.5, 1))
plt.setp(autotexts, size=10, weight=700)
ax.set_title(" test")