Skip to content

Commit ddeefa7

Browse files
committed
Trimming down plotter
1 parent 6f59874 commit ddeefa7

4 files changed

Lines changed: 22 additions & 30 deletions

File tree

dabest/misc_tools.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ def get_params(effectsize_df, plot_kwargs):
8686
plot_kwargs : dict
8787
Kwargs passed to the plot function.
8888
"""
89-
face_color = plot_kwargs["face_color"]
90-
91-
if plot_kwargs["face_color"] is None:
92-
face_color = "white"
93-
9489
dabest_obj = effectsize_df.dabest_obj
9590
plot_data = effectsize_df._plot_data
9691
xvar = effectsize_df.xvar
@@ -100,7 +95,6 @@ def get_params(effectsize_df, plot_kwargs):
10095
mini_meta = effectsize_df.mini_meta
10196
effect_size = effectsize_df.effect_size
10297
proportional = effectsize_df.proportional
103-
10498
all_plot_groups = dabest_obj._all_plot_groups
10599
idx = dabest_obj.idx
106100

@@ -144,8 +138,7 @@ def get_params(effectsize_df, plot_kwargs):
144138
if err_color is None:
145139
err_color = "black"
146140

147-
148-
return (face_color, dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx,
141+
return (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx,
149142
show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color)
150143

151144
def get_kwargs(plot_kwargs, ytick_color):
@@ -381,8 +374,13 @@ def get_color_palette(plot_kwargs, plot_data, xvar, show_pairs):
381374
bar_color, plot_palette_bar, plot_palette_contrast, plot_palette_sankey)
382375

383376
def initialize_fig(plot_kwargs, dabest_obj, show_delta2, show_mini_meta, is_paired, show_pairs, proportional,
384-
float_contrast, face_color):
377+
float_contrast):
378+
# Params
385379
fig_size = plot_kwargs["fig_size"]
380+
face_color = plot_kwargs["face_color"]
381+
if plot_kwargs["face_color"] is None:
382+
face_color = "white"
383+
386384
if fig_size is None:
387385
all_groups_count = np.sum([len(i) for i in dabest_obj.idx])
388386
# Increase the width for delta-delta graph
@@ -497,6 +495,7 @@ def get_plot_groups(is_paired, idx, proportional, all_plot_groups):
497495
# Determine temp_all_plot_groups based on proportional condition
498496
plot_groups = [item for i in temp_idx for item in i]
499497
temp_all_plot_groups = all_plot_groups if not proportional else plot_groups
498+
500499
return temp_idx, temp_all_plot_groups
501500

502501

dabest/plotter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def effectsize_df_plotter(effectsize_df, **plot_kwargs):
107107
ytick_color = plt.rcParams["ytick.color"]
108108

109109
# Extract parameters and set kwargs
110-
(face_color, dabest_obj, plot_data, xvar, yvar, is_paired, effect_size,
110+
(dabest_obj, plot_data, xvar, yvar, is_paired, effect_size,
111111
proportional, all_plot_groups, idx, show_delta2, show_mini_meta,
112112
float_contrast, show_pairs, effect_size_type, group_summaries, err_color) = get_params(
113113
effectsize_df=effectsize_df,
@@ -124,13 +124,11 @@ def effectsize_df_plotter(effectsize_df, **plot_kwargs):
124124
# We also need to extract the `sankey` and `flow` from the kwargs for plotter.py
125125
# to use for varying different kinds of paired proportional plots
126126
# We also don't want to pop the parameter from the kwargs
127-
sankey = sankey_kwargs["sankey"]
128-
flow = sankey_kwargs["flow"]
129127
one_sankey = (
130128
False if is_paired is not None else None
131129
) # Flag to indicate if only one sankey is plotted.
132130
two_col_sankey = (
133-
True if proportional and not one_sankey and sankey and not flow else False
131+
True if proportional and not one_sankey and sankey_kwargs["sankey"] and not sankey_kwargs["flow"] else False
134132
)
135133

136134
# Extract Color palette
@@ -152,8 +150,7 @@ def effectsize_df_plotter(effectsize_df, **plot_kwargs):
152150
is_paired=is_paired,
153151
show_pairs=show_pairs,
154152
proportional=proportional,
155-
float_contrast=float_contrast,
156-
face_color=face_color,
153+
float_contrast=float_contrast,
157154
)
158155

159156
# Plotting the rawdata.

nbs/API/misc_tools.ipynb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@
141141
" plot_kwargs : dict\n",
142142
" Kwargs passed to the plot function.\n",
143143
" \"\"\"\n",
144-
" face_color = plot_kwargs[\"face_color\"]\n",
145-
"\n",
146-
" if plot_kwargs[\"face_color\"] is None:\n",
147-
" face_color = \"white\"\n",
148-
"\n",
149144
" dabest_obj = effectsize_df.dabest_obj\n",
150145
" plot_data = effectsize_df._plot_data\n",
151146
" xvar = effectsize_df.xvar\n",
@@ -155,7 +150,6 @@
155150
" mini_meta = effectsize_df.mini_meta\n",
156151
" effect_size = effectsize_df.effect_size\n",
157152
" proportional = effectsize_df.proportional\n",
158-
"\n",
159153
" all_plot_groups = dabest_obj._all_plot_groups\n",
160154
" idx = dabest_obj.idx\n",
161155
"\n",
@@ -199,8 +193,7 @@
199193
" if err_color is None: \n",
200194
" err_color = \"black\"\n",
201195
" \n",
202-
"\n",
203-
" return (face_color, dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx, \n",
196+
" return (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups, idx, \n",
204197
" show_delta2, show_mini_meta, float_contrast, show_pairs, effect_size_type, group_summaries, err_color)\n",
205198
"\n",
206199
"def get_kwargs(plot_kwargs, ytick_color):\n",
@@ -436,8 +429,13 @@
436429
" bar_color, plot_palette_bar, plot_palette_contrast, plot_palette_sankey)\n",
437430
"\n",
438431
"def initialize_fig(plot_kwargs, dabest_obj, show_delta2, show_mini_meta, is_paired, show_pairs, proportional,\n",
439-
" float_contrast, face_color):\n",
432+
" float_contrast):\n",
433+
" # Params\n",
440434
" fig_size = plot_kwargs[\"fig_size\"]\n",
435+
" face_color = plot_kwargs[\"face_color\"]\n",
436+
" if plot_kwargs[\"face_color\"] is None:\n",
437+
" face_color = \"white\"\n",
438+
"\n",
441439
" if fig_size is None:\n",
442440
" all_groups_count = np.sum([len(i) for i in dabest_obj.idx])\n",
443441
" # Increase the width for delta-delta graph\n",
@@ -552,6 +550,7 @@
552550
" # Determine temp_all_plot_groups based on proportional condition\n",
553551
" plot_groups = [item for i in temp_idx for item in i]\n",
554552
" temp_all_plot_groups = all_plot_groups if not proportional else plot_groups\n",
553+
" \n",
555554
" return temp_idx, temp_all_plot_groups\n",
556555
"\n",
557556
"\n",

nbs/API/plotter.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
" ytick_color = plt.rcParams[\"ytick.color\"]\n",
167167
"\n",
168168
" # Extract parameters and set kwargs\n",
169-
" (face_color, dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, \n",
169+
" (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, \n",
170170
" proportional, all_plot_groups, idx, show_delta2, show_mini_meta, \n",
171171
" float_contrast, show_pairs, effect_size_type, group_summaries, err_color) = get_params(\n",
172172
" effectsize_df=effectsize_df, \n",
@@ -183,13 +183,11 @@
183183
" # We also need to extract the `sankey` and `flow` from the kwargs for plotter.py\n",
184184
" # to use for varying different kinds of paired proportional plots\n",
185185
" # We also don't want to pop the parameter from the kwargs\n",
186-
" sankey = sankey_kwargs[\"sankey\"]\n",
187-
" flow = sankey_kwargs[\"flow\"]\n",
188186
" one_sankey = (\n",
189187
" False if is_paired is not None else None\n",
190188
" ) # Flag to indicate if only one sankey is plotted.\n",
191189
" two_col_sankey = (\n",
192-
" True if proportional and not one_sankey and sankey and not flow else False\n",
190+
" True if proportional and not one_sankey and sankey_kwargs[\"sankey\"] and not sankey_kwargs[\"flow\"] else False\n",
193191
" )\n",
194192
"\n",
195193
" # Extract Color palette\n",
@@ -211,8 +209,7 @@
211209
" is_paired=is_paired, \n",
212210
" show_pairs=show_pairs, \n",
213211
" proportional=proportional, \n",
214-
" float_contrast=float_contrast, \n",
215-
" face_color=face_color, \n",
212+
" float_contrast=float_contrast,\n",
216213
" )\n",
217214
" \n",
218215
" # Plotting the rawdata.\n",

0 commit comments

Comments
 (0)