Untitled
unknown
plain_text
8 months ago
1.6 kB
5
Indexable
import matplotlib.pyplot as plt
import numpy as np
# Data dari tabel
indikator = ["Akauntabiliti", "Amanah", "Disiplin", "Jujur", "Kreadibiliti", "Berhemah", "Ikhlas", "Adil"]
tahap_pengajian = ["Sijil", "Asasi/Matrikulasi", "Diploma", "Ijazah Sarjana Muda", "Ijazah Sarjana", "PhD"]
nilai = [
[4.37, 4.64, 4.61, 4.28, 4.16, 4.43, 4.41, 4.40], # Sijil
[4.21, 4.45, 4.39, 4.18, 4.12, 4.29, 4.33, 4.25], # Asasi/Matrikulasi
[4.35, 4.49, 4.41, 4.23, 4.09, 4.33, 4.39, 4.27], # Diploma
[4.38, 4.54, 4.49, 4.31, 4.23, 4.42, 4.41, 4.37], # Ijazah Sarjana Muda
[4.32, 4.61, 4.53, 4.42, 4.31, 4.48, 4.42, 4.34], # Ijazah Sarjana
[4.42, 4.66, 4.58, 4.52, 4.44, 4.54, 4.53, 4.44] # PhD
]
# Warna yang sesuai untuk buku (netral & profesional)
colors = ['#2E86C1', '#AED6F1', '#5D6D7E', '#85C1E9', '#1B4F72', '#566573']
# Plotting
fig, ax = plt.subplots(figsize=(12, 6))
bar_width = 0.12
indices = np.arange(len(indikator))
for i, tahap in enumerate(tahap_pengajian):
ax.barh(indices + i * bar_width, nilai[i], height=bar_width, label=tahap, color=colors[i])
# Format sumbu dan label
ax.set_yticks(indices + bar_width * 2.5)
ax.set_yticklabels(indikator)
ax.set_xlabel("Skor Integriti")
ax.set_title("Analisis Indikator Integriti Mengikut Tahap Pengajian")
ax.legend(title="Tahap Pengajian", bbox_to_anchor=(1.05, 1), loc='upper left')
plt.grid(axis='x', linestyle="--", alpha=0.5)
plt.tight_layout()
# Simpan sebagai gambar untuk digunakan dalam buku
plt.savefig("analisis_integriti.png", dpi=300)
plt.show()
Editor is loading...
Leave a Comment