数据特征分析-对比分析

对比分析是对两个互相联系的指标进行比较。

绝对数比较(相减):指标在量级上不能差别过大,常用折线图、柱状图

相对数比较(相除):结构分析、比例分析、空间比较分析、动态对比分析

 

df = pd.DataFrame(np.random.rand(30,2)*1000,columns=['A_sale','B_sale'],index = pd.date_range('2019/6/1','2019/6/30'))
df.style.format({'A':'{:.2f}','B':'{:.2f}'})

 

#
df.plot(figsize = (10,5),linestyle ='--',title ='A_sale to B_sale:line',marker = '.')
df.plot(kind = 'bar',figsize = (12,5),title = 'A_sale to B_sale:bar',width = 0.8,alpha = 0.8)

  

 

x = range(len(df))
y1 = df['A_sale']
y2 = -df['B_sale']

fig,axes = plt.subplots(1,2,figsize = (15,5))
ax1 = axes[0]
ax1.bar(x,y1,facecolor = 'r')
ax1.bar(x,y2,facecolor = 'g')

ax2 = axes[1]
y3 = df['A_sale'] - df['B_sale']
ax2.plot(x,y3)
plt.axhline(0,linestyle = '--',color = 'r')   #在y值为0处生成一条水平线
ax2.set_xticklabels(df.index[::4])

 

 

 

https://www.cnblogs.com/shengyang17/p/9630749.html

posted @ 2019-08-13 10:38  Forever77  阅读(501)  评论(0编辑  收藏  举报