import matplotlib.pyplot as plt
import numpy as np
labels = ['2001', '2002', '2003', '2004', '2005']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
x = np.arange(len(labels))
width = 0.35
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='Pria')
rects2 = ax.bar(x + width/2, women_means, width, label='Wanita')
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.legend()
ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)
fig.tight_layout()
plt.show()
Cara plot grouped bar chart berlabel pada Python menggunakan Matplotlib
June 07, 2022
0
Berikut adalah kodingan dasar untuk mem-plot grouped bar chart berlabel pada Python menggunakan Matplotlib dan hasilnya akan seperti gambar berikut :