Cara Membuat Grafik Bar Bertingkat Python Matplotlib

Admin
0
Berikut adalah kodingan cara membuat grafik bar bertingkat Python Matplotlib dan hasilnya akan seperti gambar berikut :





import matplotlib.pyplot as plt


labels = ['2001', '2002', '2003', '2004', '2005']
men_means = [20, 35, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
men_std = [2, 3, 4, 1, 2]
women_std = [3, 5, 2, 3, 3]
width = 0.35  

fig, ax = plt.subplots()

ax.bar(labels, men_means, width, yerr=men_std, label='Pria')
ax.bar(labels, women_means, width, yerr=women_std, bottom=men_means,
       label='Wanita')

ax.set_ylabel('Nilai')
ax.set_title('Contoh Grafik Bar Bertingkat')
ax.legend()

plt.show()

Post a Comment

0Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

Disclaimer : Content provided on this page is for general informational purposes only. We make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability or completeness of any information.

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top