Skip to content

Commit 15454ca

Browse files
committed
Bug fix for y-lim issues when deltadots are shown
Remove deltadots when the effect size is hedges_g/delta_g/cohens_h. Also remove duplicate variable (effect_size and effect_size_type)
1 parent 03bd48c commit 15454ca

6 files changed

Lines changed: 20 additions & 14 deletions

File tree

dabest/misc_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ def get_params(
138138
# Disable Gardner-Altman plotting if any of the idxs comprise of more than
139139
# two groups or if it is a delta-delta plot.
140140
float_contrast = plot_kwargs["float_contrast"]
141-
effect_size_type = effectsize_df.effect_size
141+
# effect_size_type = effectsize_df.effect_size
142142
if len(idx) > 1 or len(idx[0]) > 2:
143143
float_contrast = False
144144

145-
if effect_size_type in ["cliffs_delta"]:
145+
if effect_size in ["cliffs_delta"]:
146146
float_contrast = False
147147

148148
if show_delta2 or show_mini_meta:
@@ -176,7 +176,7 @@ def get_params(
176176
show_baseline_ec = plot_kwargs["show_baseline_ec"]
177177

178178
return (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx,
179-
show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color, horizontal,
179+
show_delta2, show_mini_meta, float_contrast, show_pairs, group_summaries, err_color, horizontal,
180180
results, halfviolin_alpha, ci_type, x1_level, experiment_label, show_baseline_ec)
181181

182182
def get_kwargs(

dabest/plotter.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
118118

119119
# Extract parameters and set kwargs
120120
(dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx,
121-
show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color, horizontal,
121+
show_delta2, show_mini_meta, float_contrast, show_pairs, group_summaries, err_color, horizontal,
122122
results, halfviolin_alpha, ci_type, x1_level, experiment_label, show_baseline_ec) = get_params(
123123
effectsize_df = effectsize_df,
124124
plot_kwargs = plot_kwargs,
125125
)
126+
127+
print(effect_size)
126128

127129
(swarmplot_kwargs, barplot_kwargs, sankey_kwargs,
128130
violinplot_kwargs, slopegraph_kwargs, reflines_kwargs, legend_kwargs,
@@ -166,7 +168,7 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
166168
show_pairs = show_pairs,
167169
proportional = proportional,
168170
float_contrast = float_contrast,
169-
effect_size_type = effect_size_type,
171+
effect_size_type = effect_size,
170172
yvar = yvar,
171173
horizontal = horizontal,
172174
show_table = table_kwargs['show']
@@ -198,7 +200,8 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
198200

199201
# Add delta dots to the contrast axes for paired plots.
200202
show_delta_dots = plot_kwargs["delta_dot"]
201-
if show_delta_dots and is_paired is not None:
203+
unavailable_effect_sizes = ["hedges_g", "delta_g", "cohens_d"]
204+
if show_delta_dots and is_paired and not any([es in effect_size for es in unavailable_effect_sizes]):
202205
DeltaDotsPlotter(
203206
plot_data = plot_data,
204207
contrast_axes = contrast_axes,
@@ -424,7 +427,7 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
424427
if float_contrast and not horizontal:
425428
# For Gardner-Altman plots only.
426429
Gardner_Altman_Plot_Aesthetic_Adjustments(
427-
effect_size_type = effect_size_type,
430+
effect_size_type = effect_size,
428431
plot_data = plot_data,
429432
xvar = xvar,
430433
yvar = yvar,

nbs/API/misc_tools.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@
191191
" # Disable Gardner-Altman plotting if any of the idxs comprise of more than\n",
192192
" # two groups or if it is a delta-delta plot.\n",
193193
" float_contrast = plot_kwargs[\"float_contrast\"]\n",
194-
" effect_size_type = effectsize_df.effect_size\n",
194+
" # effect_size_type = effectsize_df.effect_size\n",
195195
" if len(idx) > 1 or len(idx[0]) > 2:\n",
196196
" float_contrast = False\n",
197197
"\n",
198-
" if effect_size_type in [\"cliffs_delta\"]:\n",
198+
" if effect_size in [\"cliffs_delta\"]:\n",
199199
" float_contrast = False\n",
200200
"\n",
201201
" if show_delta2 or show_mini_meta:\n",
@@ -229,7 +229,7 @@
229229
" show_baseline_ec = plot_kwargs[\"show_baseline_ec\"]\n",
230230
" \n",
231231
" return (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx, \n",
232-
" show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color, horizontal,\n",
232+
" show_delta2, show_mini_meta, float_contrast, show_pairs, group_summaries, err_color, horizontal,\n",
233233
" results, halfviolin_alpha, ci_type, x1_level, experiment_label, show_baseline_ec)\n",
234234
"\n",
235235
"def get_kwargs(\n",

nbs/API/plotter.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,13 @@
175175
"\n",
176176
" # Extract parameters and set kwargs\n",
177177
" (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx, \n",
178-
" show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color, horizontal,\n",
178+
" show_delta2, show_mini_meta, float_contrast, show_pairs, group_summaries, err_color, horizontal,\n",
179179
" results, halfviolin_alpha, ci_type, x1_level, experiment_label, show_baseline_ec) = get_params(\n",
180180
" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\teffectsize_df = effectsize_df, \n",
181181
" plot_kwargs = plot_kwargs,\n",
182182
" )\n",
183+
" \n",
184+
" print(effect_size)\n",
183185
"\n",
184186
" (swarmplot_kwargs, barplot_kwargs, sankey_kwargs, \n",
185187
" violinplot_kwargs, slopegraph_kwargs, reflines_kwargs, legend_kwargs,\n",
@@ -223,7 +225,7 @@
223225
" show_pairs = show_pairs, \n",
224226
" proportional = proportional, \n",
225227
" float_contrast = float_contrast,\n",
226-
" effect_size_type = effect_size_type,\n",
228+
" effect_size_type = effect_size,\n",
227229
" yvar = yvar,\n",
228230
" horizontal = horizontal,\n",
229231
" show_table = table_kwargs['show']\n",
@@ -255,7 +257,8 @@
255257
" \n",
256258
" # Add delta dots to the contrast axes for paired plots.\n",
257259
" show_delta_dots = plot_kwargs[\"delta_dot\"]\n",
258-
" if show_delta_dots and is_paired is not None:\n",
260+
" unavailable_effect_sizes = [\"hedges_g\", \"delta_g\", \"cohens_d\"]\n",
261+
" if show_delta_dots and is_paired and not any([es in effect_size for es in unavailable_effect_sizes]):\n",
259262
" DeltaDotsPlotter(\n",
260263
" plot_data = plot_data, \n",
261264
" contrast_axes = contrast_axes, \n",
@@ -481,7 +484,7 @@
481484
" if float_contrast and not horizontal:\n",
482485
" # For Gardner-Altman plots only.\n",
483486
" Gardner_Altman_Plot_Aesthetic_Adjustments(\n",
484-
" effect_size_type = effect_size_type, \n",
487+
" effect_size_type = effect_size, \n",
485488
" plot_data = plot_data, \n",
486489
" xvar = xvar, \n",
487490
" yvar = yvar, \n",
-191 Bytes
Loading
-2.6 KB
Loading

0 commit comments

Comments
 (0)