答案 0 :(得分:2)
您的意思是pd.DataFrame
。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
df2=pd.DataFrame({'Jan':np.random.randint(0,5,size=5),
'Feb':np.random.randint(0,5,size=5),
'Mar':np.random.randint(0,5,size=5),
})
df2.plot(kind='bar',stacked=True)
plt.legend(loc='upper left')
plt.show()
评论后编辑:
data = {'Company Name':['GE', 'EON', 'NGP']
, 'Sale1_percentage':[30, 23, 27]
, 'Sale2_percentage':[28, 38, 29]
, 'Sale3_percentage':[45, 44, 31]}
df1 = pd.DataFrame(data)
print(df1)
df1.plot(kind='bar',stacked=True)
plt.legend(loc='upper left')
plt.show()