利用Matplotlib製作柱狀圖

import matplotlib.pyplot as plt
plt.style.use('ggplot')
customers = ['Tom', 'Jack', 'Kevin', 'Leo', 'Faith']
customers_index = range(len(customers))
sale_amounts = [100, 150, 204, 220, 95]
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)
ax1.bar(customers_index, sale_amounts, align='center', color='darkblue')
ax1.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('left')
plt.xticks(customers_index, customers, rotation=0, fontsize='small')
plt.xlabel('Customer Name')
plt.ylabel('Sale Amount')
plt.title('Hello world')
plt.savefig('bar_01.png', dpi=400, bbox_inches='tight')
plt.show()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章