visualization
matplotlib으로 누적 barplot 그리기
hayleyhell
2023. 2. 2. 22:50
# unstack()하여 인덱스를 컬럼으로 변경하기
grouped.unstack()

grouped.unstack().plot(kind='bar')

grouped.unstack().plot(kind='bar', stacked=True)

ax = grouped.unstack().plot(kind='bar', stacked=True)
containers = ax.containers[-1]
ax.bar_label(containers, labels=[f'{x:,.0f}' for x in containers.datavalues], label_type='center')
containers0 = ax.containers[-2]
ax.bar_label(containers0, labels=[f'{x:,.0f}' for x in containers0.datavalues], label_type='center')
plt.title('Payment by Type')
plt.show()
