Skip to content

Commit 9ebbe4d

Browse files
committed
Added control lines for the horizontal table ax
1 parent 71d0d93 commit 9ebbe4d

136 files changed

Lines changed: 53 additions & 52 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dabest/_effsize_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ def plot(
12271227
horizontal_table_kwargs : dict, default None
12281228
Pass relevant keyword arguments to the horizontal table. If None, the following keywords are passed:
12291229
{'show: True, 'color' : 'yellow', 'alpha' :0.2, 'fontsize' : 12, 'text_color' : 'black',
1230-
'text_units' : None, 'paired_gap_dashes' : False, 'fontsize_label': 12, 'label': 'Δ'}
1230+
'text_units' : None, 'control_marker' : '-', 'fontsize_label': 12, 'label': 'Δ'}
12311231
12321232
gridkey_rows : list, default None
12331233
Provide a list of row labels for the gridkey. The supplied idx is

dabest/misc_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,11 @@ def get_kwargs(
390390
default_table_kwargs = {
391391
'show': True,
392392
'color' : 'yellow',
393-
'alpha' :0.2,
393+
'alpha' : 0.2,
394394
'fontsize' : 12,
395395
'text_color' : 'black',
396396
'text_units' : None,
397-
'paired_gap_dashes' : False,
397+
'control_marker' : '-',
398398
'fontsize_label': 12,
399399
'label': 'Δ'
400400
}

dabest/plot_tools.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,9 @@ def table_for_horizontal_plots(
21302130
ticks_to_plot: list,
21312131
show_mini_meta: bool,
21322132
show_delta2: bool,
2133-
table_kwargs: dict
2133+
table_kwargs: dict,
2134+
2135+
ticks_to_skip: list
21342136
):
21352137
"""
21362138
Add table axes for showing the deltas for horizontal plots.
@@ -2151,14 +2153,17 @@ def table_for_horizontal_plots(
21512153
Whether to show the delta-delta.
21522154
table_kwargs : dict
21532155
Keyword arguments for the table.
2156+
2157+
ticks_to_skip: list
2158+
List of ticks to skip in the table.
21542159
"""
21552160

21562161
table_color = table_kwargs['color']
21572162
table_alpha = table_kwargs['alpha']
21582163
table_font_size = table_kwargs['fontsize'] if table_kwargs['text_units'] == None else table_kwargs['fontsize']-2
21592164
table_text_color = table_kwargs['text_color']
21602165
text_units = '' if table_kwargs['text_units'] == None else table_kwargs['text_units']
2161-
table_gap_dashes = table_kwargs['paired_gap_dashes'] # Currently unused
2166+
control_marker = table_kwargs['control_marker'] # Currently unused
21622167
fontsize_label = table_kwargs['fontsize_label']
21632168
label = table_kwargs['label']
21642169

@@ -2179,19 +2184,12 @@ def table_for_horizontal_plots(
21792184
else:
21802185
new_ticks = ticks_to_plot.copy()
21812186
for i,loc in zip(tab.index, new_ticks):
2182-
ax.text(0.5, loc, "{:+.2f}".format(tab.iloc[i,0])+text_units,ha="center", va="center", color=table_text_color,size=table_font_size)
2183-
2184-
# ### Plot the dashes
2185-
# if show_mini_meta or show_delta2:
2186-
# no_contrast_positions = list(set([int(x-0.5) for x in ticks_to_plot[:-1]]) ^ set(np.arange(2,Num_Exps+2,1)))
2187-
# else:
2188-
# no_contrast_positions = list(set([int(x-0.5) for x in ypos]) ^ set(np.arange(0,Num_Exps,1)))
2189-
2190-
# if table_gap_dashes or not is_paired or multi_paired_control:
2191-
# if not (mini_meta or delta2):
2192-
# for i in no_contrast_positions:
2193-
# rawdata_axes.table_axes.text(0.5, i+1, "—",ha="center", va="center", color=table_text_color,size=table_font_size)
2187+
ax.text(0.5, loc, "{:+.2f}".format(tab.iloc[i,0])+text_units, ha="center", va="center", color=table_text_color, size=table_font_size)
21942188

2189+
# Plot the dashes
2190+
if control_marker is not None:
2191+
for loc in ticks_to_skip:
2192+
ax.text(0.5, loc, control_marker, ha="center", va="center", color=table_text_color, size=table_font_size)
21952193

21962194
### Parameters for table
21972195
ax.axvspan(0, 1, facecolor=table_color, alpha=table_alpha) #### Plot the background color

dabest/plotter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
350350
plot_groups = plot_groups,
351351
idx = idx,
352352
sankey_control_group = sankey_control_group if two_col_sankey else None,
353-
)
353+
)
354354

355355
# Adjust contrast tick locations to account for different plotting styles in horizontal plots
356356
table_axes_ticks_to_plot = ticks_to_plot
@@ -551,6 +551,8 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
551551
show_mini_meta = show_mini_meta,
552552
show_delta2 = show_delta2,
553553
table_kwargs = table_kwargs,
554+
555+
ticks_to_skip = ticks_to_skip
554556
)
555557

556558
# Gridkey

nbs/API/effsize_objects.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@
13861386
" horizontal_table_kwargs : dict, default None\n",
13871387
" Pass relevant keyword arguments to the horizontal table. If None, the following keywords are passed:\n",
13881388
" {'show: True, 'color' : 'yellow', 'alpha' :0.2, 'fontsize' : 12, 'text_color' : 'black', \n",
1389-
" 'text_units' : None, 'paired_gap_dashes' : False, 'fontsize_label': 12, 'label': 'Δ'}\n",
1389+
" 'text_units' : None, 'control_marker' : '-', 'fontsize_label': 12, 'label': 'Δ'}\n",
13901390
" \n",
13911391
" gridkey_rows : list, default None\n",
13921392
" Provide a list of row labels for the gridkey. The supplied idx is\n",

nbs/API/misc_tools.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@
443443
" default_table_kwargs = {\n",
444444
" 'show': True,\n",
445445
" 'color' : 'yellow',\n",
446-
" 'alpha' :0.2,\n",
446+
" 'alpha' : 0.2,\n",
447447
" 'fontsize' : 12,\n",
448448
" 'text_color' : 'black', \n",
449449
" 'text_units' : None,\n",
450-
" 'paired_gap_dashes' : False,\n",
450+
" 'control_marker' : '-',\n",
451451
" 'fontsize_label': 12,\n",
452452
" 'label': 'Δ'\n",
453453
" }\n",

nbs/API/plot_tools.ipynb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,9 @@
21802180
" ticks_to_plot: list, \n",
21812181
" show_mini_meta: bool, \n",
21822182
" show_delta2: bool, \n",
2183-
" table_kwargs: dict\n",
2183+
" table_kwargs: dict,\n",
2184+
"\n",
2185+
" ticks_to_skip: list\n",
21842186
" ):\n",
21852187
" \"\"\"\n",
21862188
" Add table axes for showing the deltas for horizontal plots.\n",
@@ -2201,14 +2203,17 @@
22012203
" Whether to show the delta-delta.\n",
22022204
" table_kwargs : dict\n",
22032205
" Keyword arguments for the table.\n",
2206+
"\n",
2207+
" ticks_to_skip: list\n",
2208+
" List of ticks to skip in the table.\n",
22042209
" \"\"\"\n",
22052210
"\n",
22062211
" table_color = table_kwargs['color']\n",
22072212
" table_alpha = table_kwargs['alpha']\n",
22082213
" table_font_size = table_kwargs['fontsize'] if table_kwargs['text_units'] == None else table_kwargs['fontsize']-2\n",
22092214
" table_text_color = table_kwargs['text_color']\n",
22102215
" text_units = '' if table_kwargs['text_units'] == None else table_kwargs['text_units']\n",
2211-
" table_gap_dashes = table_kwargs['paired_gap_dashes'] # Currently unused\n",
2216+
" control_marker = table_kwargs['control_marker'] # Currently unused\n",
22122217
" fontsize_label = table_kwargs['fontsize_label']\n",
22132218
" label = table_kwargs['label']\n",
22142219
"\n",
@@ -2229,19 +2234,12 @@
22292234
" else:\n",
22302235
" new_ticks = ticks_to_plot.copy()\n",
22312236
" for i,loc in zip(tab.index, new_ticks):\n",
2232-
" ax.text(0.5, loc, \"{:+.2f}\".format(tab.iloc[i,0])+text_units,ha=\"center\", va=\"center\", color=table_text_color,size=table_font_size)\n",
2233-
"\n",
2234-
" # ### Plot the dashes\n",
2235-
" # if show_mini_meta or show_delta2:\n",
2236-
" # no_contrast_positions = list(set([int(x-0.5) for x in ticks_to_plot[:-1]]) ^ set(np.arange(2,Num_Exps+2,1)))\n",
2237-
" # else:\n",
2238-
" # no_contrast_positions = list(set([int(x-0.5) for x in ypos]) ^ set(np.arange(0,Num_Exps,1)))\n",
2239-
"\n",
2240-
" # if table_gap_dashes or not is_paired or multi_paired_control:\n",
2241-
" # if not (mini_meta or delta2):\n",
2242-
" # for i in no_contrast_positions:\n",
2243-
" # rawdata_axes.table_axes.text(0.5, i+1, \"\",ha=\"center\", va=\"center\", color=table_text_color,size=table_font_size)\n",
2237+
" ax.text(0.5, loc, \"{:+.2f}\".format(tab.iloc[i,0])+text_units, ha=\"center\", va=\"center\", color=table_text_color, size=table_font_size)\n",
22442238
"\n",
2239+
" # Plot the dashes\n",
2240+
" if control_marker is not None:\n",
2241+
" for loc in ticks_to_skip:\n",
2242+
" ax.text(0.5, loc, control_marker, ha=\"center\", va=\"center\", color=table_text_color, size=table_font_size)\n",
22452243
"\n",
22462244
" ### Parameters for table\n",
22472245
" ax.axvspan(0, 1, facecolor=table_color, alpha=table_alpha) #### Plot the background color\n",

nbs/API/plotter.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
" plot_groups = plot_groups,\n",
408408
" idx = idx,\n",
409409
" sankey_control_group = sankey_control_group if two_col_sankey else None,\n",
410-
" )\n",
410+
" ) \n",
411411
"\n",
412412
" # Adjust contrast tick locations to account for different plotting styles in horizontal plots\n",
413413
" table_axes_ticks_to_plot = ticks_to_plot\n",
@@ -608,6 +608,8 @@
608608
" show_mini_meta = show_mini_meta,\n",
609609
" show_delta2 = show_delta2,\n",
610610
" table_kwargs = table_kwargs,\n",
611+
"\n",
612+
" ticks_to_skip = ticks_to_skip\n",
611613
" )\n",
612614
"\n",
613615
" # Gridkey\n",
69 Bytes
71 Bytes

0 commit comments

Comments
 (0)