6.7.17
Temukan faktor utama dengan diagram Pareto Untuk menunjukkan kontribusi kumulatif pada penyebab cacat atau kategori pertanyaan, diagram Pareto adalah pilihan klasik. Bar dan garis kumulatif menonjolkan titik 80/20.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
categories = [ "Salah konfigurasi" , "Cara pakai tidak jelas" , "Bug" , "Pertanyaan spesifikasi" , "Error integrasi" , "Lainnya" ]
counts = np . array ([ 120 , 95 , 70 , 45 , 30 , 18 ])
sorted_idx = np . argsort ( counts )[:: - 1 ]
counts = counts [ sorted_idx ]
categories = [ categories [ i ] for i in sorted_idx ]
cumulative = counts . cumsum () / counts . sum ()
fig , ax1 = plt . subplots ( figsize = ( 6.4 , 4 ))
ax1 . bar ( categories , counts , color = "#38bdf8" )
ax1 . set_ylabel ( "Jumlah" )
ax1 . set_title ( "Analisis Pareto kategori pertanyaan" )
ax1 . grid ( axis = "y" , alpha = 0.2 )
ax2 = ax1 . twinx ()
ax2 . plot ( categories , cumulative , color = "#ef4444" , marker = "o" )
ax2 . set_ylabel ( "Proporsi kumulatif" )
ax2 . set_ylim ( 0 , 1.05 )
ax2 . yaxis . set_major_formatter ( FuncFormatter ( lambda x , _ : f " { x : .0% } " ))
threshold = np . argmax ( cumulative >= 0.8 )
ax2 . axhline ( 0.8 , color = "#475569" , linestyle = "--" , linewidth = 1 )
ax1 . axvline ( threshold + 0.5 , color = "#475569" , linestyle = ":" , linewidth = 1 )
fig . tight_layout ()
plt . show ()
Kiat membaca
# Bar menunjukkan jumlah tiap kategori, garis menunjukkan kontribusi kumulatif. Garis 80% menandai kategori yang perlu diprioritaskan. Jika garis naik perlahan, penyebabnya tersebar dan butuh perbaikan lintas area.