如何使用matplotlib从三个不同的数据框中绘制条形图?

时间:2019-04-06 16:59:25

标签: python visualization matplotlib

我想使用matplotLib绘制具有三个不同数据框的三重条形图

DF1

str_replace

DF2

index | Number    
A     | 110    
B     | 22    
D     | 52

DF3

index | Number
A     | 100
B     | 22
C     | 52

我正在尝试使用这段代码,但这给出了错误,因为该数据需要来自同一数据帧

index | Number    
A     | 90    
B     | 12    
C     | 10

1 个答案:

答案 0 :(得分:2)

如果您愿意使用seaborn,此代码块将为您工作:

ax=DF1[["Number"]].DF2[["Number"]].DF3[["Number"]].plot(kind ='bar',log=True,title = "BarGraph",figsize=(15,10),legend=True,fontsize=10)
ax.set_xlabel("Index",fontsize=12)
ax.set_ylabel("Number",fontsize=12)
plt.show()

它应该产生这个情节:

seaborn plot

相关问题