-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoduleB.py
More file actions
34 lines (26 loc) · 1.35 KB
/
Copy pathmoduleB.py
File metadata and controls
34 lines (26 loc) · 1.35 KB
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
32
33
34
import matplotlib.pyplot as plt
import numpy as np
class Graph:
def __init__(self, distribution_instance):
self.distribution = distribution_instance
def line_chart(self):
# 데이터 내림차순 정렬
sorted_indices = np.argsort(self.distribution.score)[::-1] # 내림차순 정렬
scores = np.array(self.distribution.score)[sorted_indices]
men = np.array(self.distribution.man)[sorted_indices]
women = np.array(self.distribution.woman)[sorted_indices]
x = np.arange(len(scores))
plt.rc('font', family='NanumGothic')
fig, ax = plt.subplots(figsize=(15, 6))
# 선 그래프 생성 (선 두께와 점 크기 조정)
ax.plot(x, men, marker='o', markersize=3, linewidth=1, label='남', color='blue', alpha=0.7)
ax.plot(x, women, marker='o', markersize=3, linewidth=1, label='여', color='pink', alpha=0.7)
ax.set_xlabel('표준 점수', fontsize=12)
ax.set_ylabel('학생 수', fontsize=12)
ax.set_title(f'{int(self.distribution.year)+1}학년도 수능 {self.distribution.subject} 표준점수 분포', fontsize=14)
xticks = np.arange(0, len(scores), max(1, len(scores) // 10))
ax.set_xticks(xticks)
ax.set_xticklabels([scores[i] for i in xticks], rotation=90)
ax.legend()
plt.tight_layout()
plt.show()