Skip to content

Commit 0c8d6c5

Browse files
committed
feat(bar): support combining multiple statistical test methods
Users can now apply up to two statistical tests simultaneously, with one required to be `ttest_1samp`. For example: `test_method=["ttest_1samp", "ttest_ind"]`. If two methods are used, the asterisks from `ttest_1samp` will be shown in blue, while the color of the second method's asterisks can be customized via `asterisk_color`.
1 parent 1596c72 commit 0c8d6c5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/plotfig/bar.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,30 @@ def statistics(
218218
"test_method 最多只能有2个元素。且当元素数量为2时,其中之一必须是 'ttest_1samp'。"
219219
)
220220

221+
for method in test_method:
222+
comparisons = determine_test_modle(data, method, p_list, popmean)
223+
if not comparisons:
224+
return
225+
226+
y_max = ax.get_ylim()[1]
227+
interval = (y_max - np.max(all_values)) / (len(comparisons) + 1)
228+
229+
color = (
230+
"b"
231+
if len(test_method) > 1 and method == "ttest_1samp"
232+
else asterisk_color
233+
)
234+
235+
annotate_significance(
236+
ax,
237+
comparisons,
238+
np.max(all_values),
239+
interval,
240+
line_color=statistical_line_color,
241+
star_offset=interval / 5,
242+
fontsize=asterisk_fontsize,
243+
color=color,
244+
)
221245
else:
222246
warnings.warn(
223247
"请使用列表形式传递 test_method 参数,例如 test_method=['ttest_ind']。字符串形式 test_method='ttest_ind' 将在后续版本中弃用。",

0 commit comments

Comments
 (0)