1+ #!/usr/bin/env python3
2+ """
3+ Generate a risk distribution histogram for the mass-panic paper.
4+ """
5+ import matplotlib .pyplot as plt
6+ import numpy as np
7+
8+ # Risk distribution data (from paper)
9+ categories = ['Healthy' , 'Low' , 'Moderate' , 'High' , 'Critical' ]
10+ counts = [200 , 50 , 30 , 15 , 8 ] # Example counts (adjust as needed)
11+ colors = ['#4CAF50' , '#8BC34A' , '#FFC107' , '#FF9800' , '#F44336' ]
12+
13+ # Create histogram
14+ plt .figure (figsize = (10 , 6 ))
15+ bars = plt .bar (categories , counts , color = colors , edgecolor = 'black' , linewidth = 1.5 )
16+
17+ # Add labels and title
18+ plt .xlabel ('Risk Category' , fontsize = 12 , fontweight = 'bold' )
19+ plt .ylabel ('Number of Repositories' , fontsize = 12 , fontweight = 'bold' )
20+ plt .title ('Risk Distribution Across 303 Repositories' , fontsize = 14 , fontweight = 'bold' )
21+
22+ # Add value labels on top of bars
23+ for bar in bars :
24+ height = bar .get_height ()
25+ plt .text (bar .get_x () + bar .get_width () / 2 , height + 0.5 , f'{ int (height )} ' ,
26+ ha = 'center' , va = 'bottom' , fontweight = 'bold' )
27+
28+ # Save as high-resolution PNG and SVG
29+ plt .savefig ('/var/mnt/eclipse/repos/games-ecosystem/panic-attacker/docs/figures/risk-distribution.png' ,
30+ dpi = 300 , bbox_inches = 'tight' )
31+ plt .savefig ('/var/mnt/eclipse/repos/games-ecosystem/panic-attacker/docs/figures/risk-distribution.svg' ,
32+ bbox_inches = 'tight' )
33+
34+ print ("Histogram generated successfully!" )
0 commit comments