hossam 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hossam
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Hossam Data Helper
5
5
  Author-email: Lee Kwang-Ho <leekh4232@gmail.com>
6
6
  License-Expression: MIT
@@ -49,7 +49,7 @@ config = SimpleNamespace(
49
49
  # ===================================================================
50
50
  # 기본 크기가 설정된 Figure와 Axes를 생성한다
51
51
  # ===================================================================
52
- def get_default_ax(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None):
52
+ def get_default_ax(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str = None):
53
53
  """기본 크기의 Figure와 Axes를 생성한다.
54
54
 
55
55
  Args:
@@ -61,6 +61,7 @@ def get_default_ax(width: int = config.width, height: int = config.height, rows:
61
61
  flatten (bool): Axes 배열을 1차원 리스트로 평탄화할지 여부.
62
62
  ws (int|None): 서브플롯 가로 간격(`wspace`). rows/cols가 1보다 클 때만 적용.
63
63
  hs (int|None): 서브플롯 세로 간격(`hspace`). rows/cols가 1보다 클 때만 적용.
64
+ title (str|None): Figure 제목.
64
65
 
65
66
  Returns:
66
67
  tuple[Figure, Axes]: 생성된 matplotlib Figure와 Axes 객체.
@@ -71,6 +72,9 @@ def get_default_ax(width: int = config.width, height: int = config.height, rows:
71
72
  if (rows > 1 or cols > 1) and (ws != None and hs != None):
72
73
  fig.subplots_adjust(wspace=ws, hspace=hs)
73
74
 
75
+ if title:
76
+ fig.suptitle(title, fontsize=config.font_size * 1.5, fontweight='bold')
77
+
74
78
  if flatten == True:
75
79
  # 단일 Axes인 경우 리스트로 변환
76
80
  if rows == 1 and cols == 1:
@@ -94,10 +98,34 @@ def get_default_ax(width: int = config.width, height: int = config.height, rows:
94
98
  return fig, ax
95
99
 
96
100
 
101
+ # ===================================================================
102
+ # 기본 크기가 설정된 Figure와 Axes를 생성한다
103
+ # ===================================================================
104
+ def create_figure(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str = None):
105
+ """기본 크기의 Figure와 Axes를 생성한다. get_default_ax의 래퍼 함수.
106
+
107
+ Args:
108
+ width (int): 가로 픽셀 크기.
109
+ height (int): 세로 픽셀 크기.
110
+ rows (int): 서브플롯 행 개수.
111
+ cols (int): 서브플롯 열 개수.
112
+ dpi (int): 해상도(DPI).
113
+ flatten (bool): Axes 배열을 1차원 리스트로 평탄화할지 여부.
114
+ ws (int|None): 서브플롯 가로 간격(`wspace`). rows/cols가 1보다 클 때만 적용.
115
+ hs (int|None): 서브플롯 세로 간격(`hspace`). rows/cols가 1보다 클 때만 적용.
116
+ title (str): Figure 제목.
117
+
118
+ Returns:
119
+ tuple[Figure, Axes]: 생성된 matplotlib Figure와 Axes 객체.
120
+ """
121
+ fig, ax = get_default_ax(width, height, rows, cols, dpi, flatten, ws, hs, title)
122
+ return fig, ax
123
+
124
+
97
125
  # ===================================================================
98
126
  # 그래프의 그리드, 레이아웃을 정리하고 필요 시 저장 또는 표시한다
99
127
  # ===================================================================
100
- def finalize_plot(ax: Axes, callback: any = None, outparams: bool = False, save_path: str = None, grid: bool = True) -> None:
128
+ def finalize_plot(ax: Axes, callback: any = None, outparams: bool = False, save_path: str = None, grid: bool = True, title: str = None) -> None:
101
129
  """공통 후처리를 수행한다: 콜백 실행, 레이아웃 정리, 필요 시 표시/종료.
102
130
 
103
131
  Args:
@@ -106,7 +134,7 @@ def finalize_plot(ax: Axes, callback: any = None, outparams: bool = False, save_
106
134
  outparams (bool): 내부에서 생성한 Figure인 경우 True.
107
135
  save_path (str|None): 이미지 저장 경로. None이 아니면 해당 경로로 저장.
108
136
  grid (bool): 그리드 표시 여부. 기본값은 True입니다.
109
-
137
+ title (str|None): 그래프 제목.
110
138
  Returns:
111
139
  None
112
140
  """
@@ -131,6 +159,9 @@ def finalize_plot(ax: Axes, callback: any = None, outparams: bool = False, save_
131
159
 
132
160
  plt.tight_layout()
133
161
 
162
+ if title:
163
+ ax.set_title(title, fontsize=config.font_size * 1.3, pad=7, fontweight='bold')
164
+
134
165
  if save_path is not None:
135
166
  plt.savefig(save_path, dpi=config.dpi * 2, bbox_inches='tight')
136
167
 
@@ -139,6 +170,27 @@ def finalize_plot(ax: Axes, callback: any = None, outparams: bool = False, save_
139
170
  plt.close()
140
171
 
141
172
 
173
+ # ===================================================================
174
+ # 그래프의 그리드, 레이아웃을 정리하고 필요 시 저장 또는 표시한다
175
+ # ===================================================================
176
+ def show_figure(ax: Axes, callback: any = None, outparams: bool = False, save_path: str = None, grid: bool = True, title: str = None) -> None:
177
+ """공통 후처리를 수행한다: 콜백 실행, 레이아웃 정리, 필요 시 표시/종료.
178
+ finalize_plot의 래퍼 함수.
179
+
180
+ Args:
181
+ ax (Axes|ndarray|list): 대상 Axes (단일 Axes 또는 subplots 배열).
182
+ callback (Callable|None): 추가 설정을 위한 사용자 콜백.
183
+ outparams (bool): 내부에서 생성한 Figure인 경우 True.
184
+ save_path (str|None): 이미지 저장 경로. None이 아니면 해당 경로로 저장.
185
+ grid (bool): 그리드 표시 여부. 기본값은 True입니다.
186
+ title (str|None): 그래프 제목.
187
+
188
+ Returns:
189
+ None
190
+ """
191
+ finalize_plot(ax, callback, outparams, save_path, grid, title)
192
+
193
+
142
194
  # ===================================================================
143
195
  # 선 그래프를 그린다
144
196
  # ===================================================================
@@ -147,6 +199,7 @@ def lineplot(
147
199
  xname: str = None,
148
200
  yname: str = None,
149
201
  hue: str = None,
202
+ title: str | None = None,
150
203
  marker: str = None,
151
204
  palette: str = None,
152
205
  width: int = config.width,
@@ -165,6 +218,7 @@ def lineplot(
165
218
  xname (str|None): x축 컬럼명.
166
219
  yname (str|None): y축 컬럼명.
167
220
  hue (str|None): 범주 구분 컬럼명.
221
+ title (str|None): 그래프 제목.
168
222
  marker (str|None): 마커 모양.
169
223
  palette (str|None): 팔레트 이름.
170
224
  width (int): 캔버스 가로 픽셀.
@@ -203,7 +257,7 @@ def lineplot(
203
257
  lineplot_kwargs.update(params)
204
258
 
205
259
  sb.lineplot(**lineplot_kwargs, linewidth=linewidth)
206
- finalize_plot(ax, callback, outparams, save_path)
260
+ finalize_plot(ax, callback, outparams, save_path, True, title)
207
261
 
208
262
 
209
263
  # ===================================================================
@@ -213,6 +267,7 @@ def boxplot(
213
267
  df: DataFrame,
214
268
  xname: str = None,
215
269
  yname: str = None,
270
+ title: str | None = None,
216
271
  orient: str = "v",
217
272
  palette: str = None,
218
273
  width: int = config.width,
@@ -230,6 +285,7 @@ def boxplot(
230
285
  df (DataFrame): 시각화할 데이터.
231
286
  xname (str|None): x축 범주 컬럼명.
232
287
  yname (str|None): y축 값 컬럼명.
288
+ title (str|None): 그래프 제목.
233
289
  orient (str): 'v' 또는 'h' 방향.
234
290
  palette (str|None): 팔레트 이름.
235
291
  width (int): 캔버스 가로 픽셀.
@@ -272,7 +328,7 @@ def boxplot(
272
328
  else:
273
329
  sb.boxplot(data=df, orient=orient, ax=ax, linewidth=linewidth, **params)
274
330
 
275
- finalize_plot(ax, callback, outparams, save_path)
331
+ finalize_plot(ax, callback, outparams, save_path, True, title)
276
332
 
277
333
 
278
334
  # ===================================================================
@@ -283,6 +339,7 @@ def kdeplot(
283
339
  xname: str = None,
284
340
  yname: str = None,
285
341
  hue: str = None,
342
+ title: str | None = None,
286
343
  palette: str = None,
287
344
  fill: bool = False,
288
345
  fill_alpha: float = config.fill_alpha,
@@ -306,6 +363,7 @@ def kdeplot(
306
363
  xname (str|None): x축 컬럼명.
307
364
  yname (str|None): y축 컬럼명.
308
365
  hue (str|None): 범주 컬럼명.
366
+ title (str|None): 그래프 제목.
309
367
  palette (str|None): 팔레트 이름.
310
368
  fill (bool): 면적 채우기 여부.
311
369
  fill_alpha (float): 채움 투명도.
@@ -369,7 +427,7 @@ def kdeplot(
369
427
  axes[idx].set_title(f"Q{idx+1}: [{lo:.3g}, {hi:.3g}]")
370
428
  axes[idx].grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
371
429
 
372
- finalize_plot(axes[0], callback, outparams, save_path)
430
+ finalize_plot(axes[0], callback, outparams, save_path, True, title)
373
431
  return
374
432
 
375
433
  if ax is None:
@@ -403,7 +461,7 @@ def kdeplot(
403
461
 
404
462
  sb.kdeplot(**kdeplot_kwargs)
405
463
 
406
- finalize_plot(ax, callback, outparams, save_path)
464
+ finalize_plot(ax, callback, outparams, save_path, True, title)
407
465
 
408
466
 
409
467
  # ===================================================================
@@ -412,8 +470,9 @@ def kdeplot(
412
470
  def histplot(
413
471
  df: DataFrame,
414
472
  xname: str,
415
- hue=None,
416
- bins=None,
473
+ hue: str | None = None,
474
+ title: str | None = None,
475
+ bins: int | None = None,
417
476
  kde: bool = True,
418
477
  palette: str = None,
419
478
  width: int = config.width,
@@ -431,6 +490,7 @@ def histplot(
431
490
  df (DataFrame): 시각화할 데이터.
432
491
  xname (str): 히스토그램 대상 컬럼명.
433
492
  hue (str|None): 범주 컬럼명.
493
+ title (str|None): 그래프 제목.
434
494
  bins (int|sequence|None): 구간 수 또는 경계.
435
495
  kde (bool): KDE 표시 여부.
436
496
  palette (str|None): 팔레트 이름.
@@ -487,7 +547,7 @@ def histplot(
487
547
  histplot_kwargs.update(params)
488
548
  sb.histplot(**histplot_kwargs)
489
549
 
490
- finalize_plot(ax, callback, outparams, save_path)
550
+ finalize_plot(ax, callback, outparams, save_path, True, title)
491
551
 
492
552
 
493
553
  # ===================================================================
@@ -497,6 +557,7 @@ def stackplot(
497
557
  df: DataFrame,
498
558
  xname: str,
499
559
  hue: str,
560
+ title: str | None = None,
500
561
  palette: str = None,
501
562
  width: int = config.width,
502
563
  height: int = config.height,
@@ -513,6 +574,7 @@ def stackplot(
513
574
  df (DataFrame): 시각화할 데이터.
514
575
  xname (str): x축 기준 컬럼.
515
576
  hue (str): 클래스 컬럼.
577
+ title (str|None): 그래프 제목.
516
578
  palette (str|None): 팔레트 이름.
517
579
  width (int): 캔버스 가로 픽셀.
518
580
  height (int): 캔버스 세로 픽셀.
@@ -571,7 +633,7 @@ def stackplot(
571
633
  ax.set_xticks(xticks)
572
634
  ax.set_xticklabels(xticks)
573
635
 
574
- finalize_plot(ax, callback, outparams, save_path)
636
+ finalize_plot(ax, callback, outparams, save_path, True, title)
575
637
 
576
638
 
577
639
  # ===================================================================
@@ -582,6 +644,7 @@ def scatterplot(
582
644
  xname: str,
583
645
  yname: str,
584
646
  hue=None,
647
+ title: str | None = None,
585
648
  palette: str = None,
586
649
  width: int = config.width,
587
650
  height: int = config.height,
@@ -599,6 +662,7 @@ def scatterplot(
599
662
  xname (str): x축 컬럼.
600
663
  yname (str): y축 컬럼.
601
664
  hue (str|None): 범주 컬럼.
665
+ title (str|None): 그래프 제목.
602
666
  palette (str|None): 팔레트 이름.
603
667
  width (int): 캔버스 가로 픽셀.
604
668
  height (int): 캔버스 세로 픽셀.
@@ -636,7 +700,7 @@ def scatterplot(
636
700
 
637
701
  sb.scatterplot(**scatterplot_kwargs)
638
702
 
639
- finalize_plot(ax, callback, outparams, save_path)
703
+ finalize_plot(ax, callback, outparams, save_path, True, title)
640
704
 
641
705
 
642
706
  # ===================================================================
@@ -646,6 +710,7 @@ def regplot(
646
710
  df: DataFrame,
647
711
  xname: str,
648
712
  yname: str,
713
+ title: str | None = None,
649
714
  palette: str = None,
650
715
  width: int = config.width,
651
716
  height: int = config.height,
@@ -662,6 +727,7 @@ def regplot(
662
727
  df (DataFrame): 시각화할 데이터.
663
728
  xname (str): 독립변수 컬럼.
664
729
  yname (str): 종속변수 컬럼.
730
+ title (str|None): 그래프 제목.
665
731
  palette (str|None): 선/점 색상.
666
732
  width (int): 캔버스 가로 픽셀.
667
733
  height (int): 캔버스 세로 픽셀.
@@ -702,7 +768,7 @@ def regplot(
702
768
 
703
769
  sb.regplot(**regplot_kwargs)
704
770
 
705
- finalize_plot(ax, callback, outparams, save_path)
771
+ finalize_plot(ax, callback, outparams, save_path, True, title)
706
772
 
707
773
 
708
774
  # ===================================================================
@@ -713,6 +779,7 @@ def lmplot(
713
779
  xname: str,
714
780
  yname: str,
715
781
  hue=None,
782
+ title: str | None = None,
716
783
  palette: str = None,
717
784
  width: int = config.width,
718
785
  height: int = config.height,
@@ -728,6 +795,7 @@ def lmplot(
728
795
  xname (str): 독립변수 컬럼.
729
796
  yname (str): 종속변수 컬럼.
730
797
  hue (str|None): 범주 컬럼.
798
+ title (str|None): 그래프 제목.
731
799
  palette (str|None): 팔레트 이름.
732
800
  width (int): 캔버스 가로 픽셀.
733
801
  height (int): 캔버스 세로 픽셀.
@@ -766,6 +834,9 @@ def lmplot(
766
834
 
767
835
  g.fig.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
768
836
 
837
+ if title:
838
+ g.fig.suptitle(title, fontsize=config.font_size * 1.5, fontweight='bold')
839
+
769
840
  plt.tight_layout()
770
841
 
771
842
  if save_path is not None:
@@ -781,6 +852,7 @@ def lmplot(
781
852
  def pairplot(
782
853
  df: DataFrame,
783
854
  xnames=None,
855
+ title: str | None = None,
784
856
  diag_kind: str = "kde",
785
857
  hue=None,
786
858
  palette: str = None,
@@ -800,6 +872,7 @@ def pairplot(
800
872
  - str: 해당 컬럼에 대해서만 처리.
801
873
  - list: 주어진 컬럼들에 대해서만 처리.
802
874
  기본값은 None.
875
+ title (str|None): 그래프 제목.
803
876
  diag_kind (str): 대각선 플롯 종류('kde' 등).
804
877
  hue (str|None): 범주 컬럼.
805
878
  palette (str|None): 팔레트 이름.
@@ -852,6 +925,10 @@ def pairplot(
852
925
  scale = len(target_cols)
853
926
  g.fig.set_size_inches(w=(width / dpi) * scale, h=(height / dpi) * scale)
854
927
  g.fig.set_dpi(dpi)
928
+
929
+ if title:
930
+ g.fig.suptitle(title, fontsize=config.font_size * 1.5, fontweight='bold')
931
+
855
932
  g.map_lower(func=sb.kdeplot, fill=True, alpha=config.fill_alpha, linewidth=linewidth)
856
933
  g.map_upper(func=sb.scatterplot, linewidth=linewidth)
857
934
 
@@ -876,6 +953,7 @@ def countplot(
876
953
  df: DataFrame,
877
954
  xname: str,
878
955
  hue=None,
956
+ title: str | None = None,
879
957
  palette: str = None,
880
958
  order: int = 1,
881
959
  width: int = config.width,
@@ -893,6 +971,7 @@ def countplot(
893
971
  df (DataFrame): 시각화할 데이터.
894
972
  xname (str): 범주 컬럼.
895
973
  hue (str|None): 보조 범주 컬럼.
974
+ title (str|None): 그래프 제목.
896
975
  palette (str|None): 팔레트 이름.
897
976
  order (int): 숫자형일 때 정렬 방식(1: 값 기준, 기타: 빈도 기준).
898
977
  width (int): 캔버스 가로 픽셀.
@@ -938,7 +1017,7 @@ def countplot(
938
1017
 
939
1018
  sb.countplot(**countplot_kwargs)
940
1019
 
941
- finalize_plot(ax, callback, outparams, save_path)
1020
+ finalize_plot(ax, callback, outparams, save_path, True, title)
942
1021
 
943
1022
 
944
1023
  # ===================================================================
@@ -949,6 +1028,7 @@ def barplot(
949
1028
  xname: str,
950
1029
  yname: str,
951
1030
  hue=None,
1031
+ title: str | None = None,
952
1032
  palette: str = None,
953
1033
  width: int = config.width,
954
1034
  height: int = config.height,
@@ -966,6 +1046,7 @@ def barplot(
966
1046
  xname (str): 범주 컬럼.
967
1047
  yname (str): 값 컬럼.
968
1048
  hue (str|None): 보조 범주 컬럼.
1049
+ title (str|None): 그래프 제목.
969
1050
  palette (str|None): 팔레트 이름.
970
1051
  width (int): 캔버스 가로 픽셀.
971
1052
  height (int): 캔버스 세로 픽셀.
@@ -1002,7 +1083,7 @@ def barplot(
1002
1083
  barplot_kwargs.update(params)
1003
1084
 
1004
1085
  sb.barplot(**barplot_kwargs)
1005
- finalize_plot(ax, callback, outparams, save_path)
1086
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1006
1087
 
1007
1088
 
1008
1089
  # ===================================================================
@@ -1013,6 +1094,7 @@ def boxenplot(
1013
1094
  xname: str,
1014
1095
  yname: str,
1015
1096
  hue=None,
1097
+ title: str | None = None,
1016
1098
  palette: str = None,
1017
1099
  width: int = config.width,
1018
1100
  height: int = config.height,
@@ -1030,6 +1112,7 @@ def boxenplot(
1030
1112
  xname (str): 범주 컬럼.
1031
1113
  yname (str): 값 컬럼.
1032
1114
  hue (str|None): 보조 범주 컬럼.
1115
+ title (str|None): 그래프 제목.
1033
1116
  palette (str|None): 팔레트 이름.
1034
1117
  width (int): 캔버스 가로 픽셀.
1035
1118
  height (int): 캔버스 세로 픽셀.
@@ -1064,7 +1147,7 @@ def boxenplot(
1064
1147
  boxenplot_kwargs.update(params)
1065
1148
 
1066
1149
  sb.boxenplot(**boxenplot_kwargs)
1067
- finalize_plot(ax, callback, outparams, save_path)
1150
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1068
1151
 
1069
1152
 
1070
1153
  # ===================================================================
@@ -1075,6 +1158,7 @@ def violinplot(
1075
1158
  xname: str,
1076
1159
  yname: str,
1077
1160
  hue=None,
1161
+ title: str | None = None,
1078
1162
  palette: str = None,
1079
1163
  width: int = config.width,
1080
1164
  height: int = config.height,
@@ -1092,6 +1176,7 @@ def violinplot(
1092
1176
  xname (str): 범주 컬럼.
1093
1177
  yname (str): 값 컬럼.
1094
1178
  hue (str|None): 보조 범주 컬럼.
1179
+ title (str|None): 그래프 제목.
1095
1180
  palette (str|None): 팔레트 이름.
1096
1181
  width (int): 캔버스 가로 픽셀.
1097
1182
  height (int): 캔버스 세로 픽셀.
@@ -1125,7 +1210,7 @@ def violinplot(
1125
1210
 
1126
1211
  violinplot_kwargs.update(params)
1127
1212
  sb.violinplot(**violinplot_kwargs)
1128
- finalize_plot(ax, callback, outparams, save_path)
1213
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1129
1214
 
1130
1215
 
1131
1216
  # ===================================================================
@@ -1136,6 +1221,7 @@ def pointplot(
1136
1221
  xname: str,
1137
1222
  yname: str,
1138
1223
  hue=None,
1224
+ title: str | None = None,
1139
1225
  palette: str = None,
1140
1226
  width: int = config.width,
1141
1227
  height: int = config.height,
@@ -1153,6 +1239,7 @@ def pointplot(
1153
1239
  xname (str): 범주 컬럼.
1154
1240
  yname (str): 값 컬럼.
1155
1241
  hue (str|None): 보조 범주 컬럼.
1242
+ title (str|None): 그래프 제목.
1156
1243
  palette (str|None): 팔레트 이름.
1157
1244
  width (int): 캔버스 가로 픽셀.
1158
1245
  height (int): 캔버스 세로 픽셀.
@@ -1188,7 +1275,7 @@ def pointplot(
1188
1275
 
1189
1276
  pointplot_kwargs.update(params)
1190
1277
  sb.pointplot(**pointplot_kwargs)
1191
- finalize_plot(ax, callback, outparams, save_path)
1278
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1192
1279
 
1193
1280
 
1194
1281
  # ===================================================================
@@ -1199,6 +1286,7 @@ def jointplot(
1199
1286
  xname: str,
1200
1287
  yname: str,
1201
1288
  hue=None,
1289
+ title: str | None = None,
1202
1290
  palette: str = None,
1203
1291
  width: int = config.width,
1204
1292
  height: int = config.height,
@@ -1214,6 +1302,7 @@ def jointplot(
1214
1302
  xname (str): x축 컬럼.
1215
1303
  yname (str): y축 컬럼.
1216
1304
  hue (str|None): 범주 컬럼.
1305
+ title (str|None): 그래프 제목.
1217
1306
  palette (str|None): 팔레트 이름.
1218
1307
  width (int): 캔버스 가로 픽셀.
1219
1308
  height (int): 캔버스 세로 픽셀.
@@ -1243,6 +1332,9 @@ def jointplot(
1243
1332
  g.fig.set_size_inches(width / dpi, height / dpi)
1244
1333
  g.fig.set_dpi(dpi)
1245
1334
 
1335
+ if title:
1336
+ g.fig.suptitle(title, fontsize=config.font_size * 1.5, fontweight='bold')
1337
+
1246
1338
  # 중앙 및 주변 플롯에 grid 추가
1247
1339
  g.ax_joint.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
1248
1340
  g.ax_marg_x.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
@@ -1262,6 +1354,7 @@ def jointplot(
1262
1354
  # ===================================================================
1263
1355
  def heatmap(
1264
1356
  data: DataFrame,
1357
+ title: str | None = None,
1265
1358
  palette: str = None,
1266
1359
  width: int | None = None,
1267
1360
  height: int | None = None,
@@ -1276,6 +1369,7 @@ def heatmap(
1276
1369
 
1277
1370
  Args:
1278
1371
  data (DataFrame): 행렬 형태 데이터.
1372
+ title (str|None): 그래프 제목.
1279
1373
  palette (str|None): 컬러맵 이름.
1280
1374
  width (int|None): 캔버스 가로 픽셀. None이면 자동 계산.
1281
1375
  height (int|None): 캔버스 세로 픽셀. None이면 자동 계산.
@@ -1313,7 +1407,7 @@ def heatmap(
1313
1407
  # heatmap은 hue를 지원하지 않으므로 cmap에 palette 사용
1314
1408
  sb.heatmap(**heatmatp_kwargs)
1315
1409
 
1316
- finalize_plot(ax, callback, outparams, save_path, False)
1410
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1317
1411
 
1318
1412
 
1319
1413
  # ===================================================================
@@ -1324,6 +1418,7 @@ def convex_hull(
1324
1418
  xname: str,
1325
1419
  yname: str,
1326
1420
  hue: str,
1421
+ title: str | None = None,
1327
1422
  palette: str = None,
1328
1423
  width: int = config.width,
1329
1424
  height: int = config.height,
@@ -1341,6 +1436,7 @@ def convex_hull(
1341
1436
  xname (str): x축 컬럼.
1342
1437
  yname (str): y축 컬럼.
1343
1438
  hue (str): 클러스터/범주 컬럼.
1439
+ title (str|None): 그래프 제목.
1344
1440
  palette (str|None): 팔레트 이름.
1345
1441
  width (int): 캔버스 가로 픽셀.
1346
1442
  height (int): 캔버스 세로 픽셀.
@@ -1385,7 +1481,7 @@ def convex_hull(
1385
1481
  sb.scatterplot(
1386
1482
  data=data, x=xname, y=yname, hue=hue, palette=palette, ax=ax, **params
1387
1483
  )
1388
- finalize_plot(ax, callback, outparams, save_path)
1484
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1389
1485
 
1390
1486
 
1391
1487
  # ===================================================================
@@ -1394,10 +1490,12 @@ def convex_hull(
1394
1490
  def kde_confidence_interval(
1395
1491
  data: DataFrame,
1396
1492
  xnames=None,
1493
+ title: str | None = None,
1397
1494
  clevel=0.95,
1398
1495
  width: int = config.width,
1399
1496
  height: int = config.height,
1400
1497
  linewidth: float = config.line_width,
1498
+ fill: bool = False,
1401
1499
  dpi: int = config.dpi,
1402
1500
  save_path: str = None,
1403
1501
  callback: any = None,
@@ -1412,10 +1510,12 @@ def kde_confidence_interval(
1412
1510
  - str: 해당 컬럼에 대해서만 처리.
1413
1511
  - list: 주어진 컬럼들에 대해서만 처리.
1414
1512
  기본값은 None.
1513
+ title (str|None): 그래프 제목.
1415
1514
  clevel (float): 신뢰수준(0~1).
1416
1515
  width (int): 캔버스 가로 픽셀.
1417
1516
  height (int): 캔버스 세로 픽셀.
1418
1517
  linewidth (float): 선 굵기.
1518
+ fill (bool): KDE 채우기 여부.
1419
1519
  dpi (int): 그림 크기 및 해상도.
1420
1520
  callback (Callable|None): Axes 후처리 콜백.
1421
1521
  ax (Axes|None): 외부에서 전달한 Axes.
@@ -1469,7 +1569,7 @@ def kde_confidence_interval(
1469
1569
  cmin, cmax = t.interval(clevel, dof, loc=sample_mean, scale=sample_std_error)
1470
1570
 
1471
1571
  # 현재 컬럼에 대한 커널밀도추정
1472
- sb.kdeplot(data=column, linewidth=linewidth, ax=current_ax)
1572
+ sb.kdeplot(data=column, linewidth=linewidth, ax=current_ax, fill=fill, alpha=config.fill_alpha)
1473
1573
 
1474
1574
  # 그래프 축의 범위
1475
1575
  xmin, xmax, ymin, ymax = current_ax.get_position().bounds
@@ -1494,7 +1594,7 @@ def kde_confidence_interval(
1494
1594
 
1495
1595
  current_ax.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
1496
1596
 
1497
- finalize_plot(axes[0] if isinstance(axes, list) and len(axes) > 0 else ax, callback, outparams, save_path)
1597
+ finalize_plot(axes[0] if isinstance(axes, list) and len(axes) > 0 else ax, callback, outparams, save_path, True, title)
1498
1598
 
1499
1599
 
1500
1600
  # ===================================================================
@@ -1504,6 +1604,7 @@ def pvalue1_anotation(
1504
1604
  data: DataFrame,
1505
1605
  target: str,
1506
1606
  hue: str,
1607
+ title: str | None = None,
1507
1608
  pairs: list = None,
1508
1609
  test: str = "t-test_ind",
1509
1610
  text_format: str = "star",
@@ -1523,6 +1624,7 @@ def pvalue1_anotation(
1523
1624
  data (DataFrame): 시각화할 데이터.
1524
1625
  target (str): 값 컬럼명.
1525
1626
  hue (str): 그룹 컬럼명.
1627
+ title (str|None): 그래프 제목.
1526
1628
  pairs (list|None): 비교할 (group_a, group_b) 튜플 목록. None이면 hue 컬럼의 모든 고유값 조합을 자동 생성.
1527
1629
  test (str): 적용할 통계 검정 이름.
1528
1630
  text_format (str): 주석 형식('star' 등).
@@ -1574,7 +1676,7 @@ def pvalue1_anotation(
1574
1676
  annotator.apply_and_annotate()
1575
1677
 
1576
1678
  sb.despine()
1577
- finalize_plot(ax, callback, outparams, save_path)
1679
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1578
1680
 
1579
1681
 
1580
1682
 
@@ -1583,6 +1685,7 @@ def pvalue1_anotation(
1583
1685
  # ===================================================================
1584
1686
  def ols_residplot(
1585
1687
  fit,
1688
+ title: str | None = None,
1586
1689
  lowess: bool = False,
1587
1690
  mse: bool = False,
1588
1691
  width: int = config.width,
@@ -1603,6 +1706,7 @@ def ols_residplot(
1603
1706
  Args:
1604
1707
  fit: 회귀 모형 객체 (statsmodels의 RegressionResultsWrapper).
1605
1708
  fit.resid와 fit.fittedvalues를 통해 잔차와 적합값을 추출한다.
1709
+ title (str|None): 그래프 제목.
1606
1710
  lowess (bool): LOWESS 스무딩 적용 여부.
1607
1711
  mse (bool): √MSE, 2√MSE, 3√MSE 대역선과 비율 표시 여부.
1608
1712
  width (int): 캔버스 가로 픽셀.
@@ -1702,7 +1806,7 @@ def ols_residplot(
1702
1806
  color=c,
1703
1807
  )
1704
1808
 
1705
- finalize_plot(ax, callback, outparams, save_path)
1809
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1706
1810
 
1707
1811
 
1708
1812
  # ===================================================================
@@ -1710,6 +1814,7 @@ def ols_residplot(
1710
1814
  # ===================================================================
1711
1815
  def ols_qqplot(
1712
1816
  fit,
1817
+ title: str | None = None,
1713
1818
  line: str = 's',
1714
1819
  width: int = config.width,
1715
1820
  height: int = config.height,
@@ -1728,6 +1833,7 @@ def ols_qqplot(
1728
1833
  Args:
1729
1834
  fit: 회귀 모형 객체 (statsmodels의 RegressionResultsWrapper 등).
1730
1835
  fit.resid 속성을 통해 잔차를 추출하여 정규성을 확인한다.
1836
+ title (str|None): 그래프 제목.
1731
1837
  line (str): 참조선의 유형. 기본값 's' (standardized).
1732
1838
  - 's': 표본의 표준편차와 평균을 기반으로 조정된 선 (권장)
1733
1839
  - 'r': 실제 점들에 대한 회귀선 (데이터 추세 반영)
@@ -1788,7 +1894,7 @@ def ols_qqplot(
1788
1894
  if line.get_linestyle() == '--' or line.get_color() == 'r':
1789
1895
  line.set_linewidth(linewidth)
1790
1896
 
1791
- finalize_plot(ax, callback, outparams, save_path)
1897
+ finalize_plot(ax, callback, outparams, save_path, True, title)
1792
1898
 
1793
1899
 
1794
1900
  # ===================================================================
@@ -1796,6 +1902,7 @@ def ols_qqplot(
1796
1902
  # ===================================================================
1797
1903
  def distribution_by_class(
1798
1904
  data: DataFrame,
1905
+ title: str | None = None,
1799
1906
  xnames: list = None,
1800
1907
  hue: str = None,
1801
1908
  type: str = "kde",
@@ -1815,6 +1922,7 @@ def distribution_by_class(
1815
1922
  data (DataFrame): 시각화할 데이터.
1816
1923
  xnames (list|None): 대상 컬럼 목록(None이면 전 컬럼).
1817
1924
  hue (str|None): 클래스 컬럼.
1925
+ title (str|None): 그래프 제목.
1818
1926
  type (str): 'kde' | 'hist' | 'histkde'.
1819
1927
  bins (int|sequence|None): 히스토그램 구간.
1820
1928
  palette (str|None): 팔레트 이름.
@@ -1897,6 +2005,7 @@ def scatter_by_class(
1897
2005
  yname: str,
1898
2006
  group: list | None = None,
1899
2007
  hue: str | None = None,
2008
+ title: str | None = None,
1900
2009
  palette: str | None = None,
1901
2010
  outline: bool = False,
1902
2011
  width: int = config.width,
@@ -1913,6 +2022,7 @@ def scatter_by_class(
1913
2022
  yname (str): 종속변수 컬럼명(필수).
1914
2023
  group (list|None): x 컬럼 목록 또는 [[x, y], ...] 형태. None이면 자동 생성.
1915
2024
  hue (str|None): 클래스 컬럼.
2025
+ title (str|None): 그래프 제목.
1916
2026
  palette (str|None): 팔레트 이름.
1917
2027
  outline (bool): 볼록 껍질을 표시할지 여부.
1918
2028
  width (int): 캔버스 가로 픽셀.
@@ -1968,6 +2078,7 @@ def categorical_target_distribution(
1968
2078
  data: DataFrame,
1969
2079
  yname: str,
1970
2080
  hue: list | str | None = None,
2081
+ title: str | None = None,
1971
2082
  kind: str = "box",
1972
2083
  kde_fill: bool = True,
1973
2084
  palette: str | None = None,
@@ -1985,6 +2096,7 @@ def categorical_target_distribution(
1985
2096
  data (DataFrame): 시각화할 데이터.
1986
2097
  yname (str): 종속변수 컬럼명(연속형 추천).
1987
2098
  hue (list|str|None): 명목형 독립변수 목록. None이면 자동 탐지.
2099
+ title (str|None): 그래프 제목.
1988
2100
  kind (str): 'box', 'violin', 'kde'.
1989
2101
  kde_fill (bool): kind='kde'일 때 영역 채우기 여부.
1990
2102
  palette (str|None): 팔레트 이름.
@@ -2043,7 +2155,7 @@ def categorical_target_distribution(
2043
2155
  for j in range(n_plots, len(axes)):
2044
2156
  axes[j].set_visible(False)
2045
2157
 
2046
- finalize_plot(axes[0], callback, outparams, save_path)
2158
+ finalize_plot(axes[0], callback, outparams, save_path, True, title)
2047
2159
 
2048
2160
 
2049
2161
  # ===================================================================
@@ -2053,6 +2165,7 @@ def roc_curve_plot(
2053
2165
  fit,
2054
2166
  y: np.ndarray | pd.Series = None,
2055
2167
  X: pd.DataFrame | np.ndarray = None,
2168
+ title: str | None = None,
2056
2169
  width: int = config.height,
2057
2170
  height: int = config.height,
2058
2171
  linewidth: float = config.line_width,
@@ -2067,6 +2180,7 @@ def roc_curve_plot(
2067
2180
  fit: statsmodels Logit 결과 객체 (`fit.predict()`로 예측 확률을 계산 가능해야 함).
2068
2181
  y (array-like|None): 외부 데이터의 실제 레이블. 제공 시 이를 실제값으로 사용.
2069
2182
  X (array-like|None): 외부 데이터의 설계행렬(독립변수). 제공 시 해당 데이터로 예측 확률 계산.
2183
+ title (str|None): 그래프 제목.
2070
2184
  width (int): 캔버스 가로 픽셀.
2071
2185
  height (int): 캔버스 세로 픽셀.
2072
2186
  linewidth (float): 선 굵기.
@@ -2113,7 +2227,7 @@ def roc_curve_plot(
2113
2227
  ax.set_ylabel('재현율 (True Positive Rate)', fontsize=8)
2114
2228
  ax.set_title('ROC 곡선', fontsize=10, fontweight='bold')
2115
2229
  ax.legend(loc="lower right", fontsize=7)
2116
- finalize_plot(ax, callback, outparams, save_path)
2230
+ finalize_plot(ax, callback, outparams, save_path, True, title)
2117
2231
 
2118
2232
 
2119
2233
  # ===================================================================
@@ -2121,6 +2235,7 @@ def roc_curve_plot(
2121
2235
  # ===================================================================
2122
2236
  def confusion_matrix_plot(
2123
2237
  fit,
2238
+ title: str | None = None,
2124
2239
  threshold: float = 0.5,
2125
2240
  width: int = config.width,
2126
2241
  height: int = config.height,
@@ -2133,6 +2248,7 @@ def confusion_matrix_plot(
2133
2248
 
2134
2249
  Args:
2135
2250
  fit: statsmodels Logit 결과 객체 (`fit.predict()`로 예측 확률을 계산 가능해야 함).
2251
+ title (str|None): 그래프 제목.
2136
2252
  threshold (float): 예측 확률을 이진 분류로 변환할 임계값. 기본값 0.5.
2137
2253
  width (int): 캔버스 가로 픽셀.
2138
2254
  height (int): 캔버스 세로 픽셀.
@@ -2163,7 +2279,7 @@ def confusion_matrix_plot(
2163
2279
 
2164
2280
  ax.set_title(f'혼동행렬 (임계값: {threshold})', fontsize=8, fontweight='bold')
2165
2281
 
2166
- finalize_plot(ax, callback, outparams, save_path, False)
2282
+ finalize_plot(ax, callback, outparams, save_path, False, title)
2167
2283
 
2168
2284
 
2169
2285
  # ===================================================================
@@ -2173,6 +2289,7 @@ def radarplot(
2173
2289
  df: DataFrame,
2174
2290
  columns: list = None,
2175
2291
  hue: str = None,
2292
+ title: str | None = None,
2176
2293
  normalize: bool = True,
2177
2294
  fill: bool = True,
2178
2295
  fill_alpha: float = 0.25,
@@ -2192,6 +2309,7 @@ def radarplot(
2192
2309
  df (DataFrame): 시각화할 데이터.
2193
2310
  columns (list|None): 레이더 차트에 표시할 컬럼 목록. None이면 모든 숫자형 컬럼 사용.
2194
2311
  hue (str|None): 집단 구분 컬럼. None이면 각 행을 개별 객체로 표시.
2312
+ title (str|None): 그래프 제목.
2195
2313
  normalize (bool): 0-1 범위로 정규화 여부. 기본값 True.
2196
2314
  fill (bool): 영역 채우기 여부.
2197
2315
  fill_alpha (float): 채움 투명도.
@@ -2293,7 +2411,7 @@ def radarplot(
2293
2411
  else:
2294
2412
  ax.set_title('Radar Chart', pad=20)
2295
2413
 
2296
- finalize_plot(ax, callback, outparams, save_path)
2414
+ finalize_plot(ax, callback, outparams, save_path, True, title)
2297
2415
 
2298
2416
 
2299
2417
  # ===================================================================
@@ -2302,6 +2420,7 @@ def radarplot(
2302
2420
  def distribution_plot(
2303
2421
  data: DataFrame,
2304
2422
  column: str,
2423
+ title: str | None = None,
2305
2424
  clevel: float = 0.95,
2306
2425
  orient: str = "h",
2307
2426
  hue: str | None = None,
@@ -2322,6 +2441,7 @@ def distribution_plot(
2322
2441
  Args:
2323
2442
  data (DataFrame): 시각화할 데이터.
2324
2443
  column (str): 분석할 컬럼명.
2444
+ title (str|None): 그래프 제목.
2325
2445
  clevel (float): KDE 신뢰수준 (0~1). 기본값 0.95.
2326
2446
  orient (str): Boxplot 방향 ('v' 또는 'h'). 기본값 'h'.
2327
2447
  hue (str|None): 명목형 컬럼명. 지정하면 각 범주별로 행을 늘려 KDE와 boxplot을 그림.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hossam
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Hossam Data Helper
5
5
  Author-email: Lee Kwang-Ho <leekh4232@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hossam"
7
- version = "0.4.2"
7
+ version = "0.4.3"
8
8
  description = "Hossam Data Helper"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes