Skip to content

Commit 04377cd

Browse files
Jacobluke-JAnns98
authored andcommitted
Solving plot_palette_bar, Seaborn issue and Sankey
1 parent 6b095c5 commit 04377cd

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

dabest/misc_tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,12 @@ def get_color_palette(
590590
if color_by_subgroups:
591591
plot_palette_raw = dict()
592592
plot_palette_contrast = dict()
593-
# plot_palette_bar set to None because currently there is no empty_circle toggle for proportion plots
594-
plot_palette_bar = None
593+
plot_palette_bar = dict()
595594
for i in range(len(idx)):
596595
for names_i in idx[i]:
597596
plot_palette_raw[names_i] = swarm_colors[i]
598597
plot_palette_contrast[names_i] = contrast_colors[i]
598+
plot_palette_bar[names_i] = bar_color[i]
599599
else:
600600
plot_palette_raw = dict(zip(categories, swarm_colors))
601601
plot_palette_contrast = dict(zip(categories, contrast_colors))
@@ -612,11 +612,12 @@ def get_color_palette(
612612
if color_by_subgroups:
613613
plot_palette_raw = dict()
614614
plot_palette_contrast = dict()
615-
plot_palette_bar = None # plot_palette_bar set to None because currently there is no empty_circle toggle for proportion plots
615+
plot_palette_bar = dict()
616616
for i in range(len(idx)):
617617
for names_i in idx[i]:
618618
plot_palette_raw[names_i] = swarm_colors[i]
619619
plot_palette_contrast[names_i] = contrast_colors[i]
620+
plot_palette_bar[names_i] = bar_color[i]
620621
else:
621622
plot_palette_raw = dict(zip(names, swarm_colors))
622623
plot_palette_contrast = dict(zip(names, contrast_colors))

dabest/plot_tools.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,17 @@ def sankeydiag(
731731
right_idx = []
732732
# Design for Sankey Flow Diagram
733733
sankey_idx = (
734-
[
735-
(control, test)
736-
for i in idx
737-
for control, test in zip(i[:], (i[1:] + (i[0],)))
738-
]
739-
if flow
740-
else temp_idx
741-
)
734+
[
735+
(control, test)
736+
for i in idx
737+
for control, test in zip(
738+
i[:],
739+
(tuple(i[1:]) + (i[0],)) if isinstance(i, tuple) else (list(i[1:]) + [i[0]])
740+
)
741+
]
742+
if flow
743+
else temp_idx
744+
)
742745
for i in sankey_idx:
743746
left_idx.append(i[0])
744747
right_idx.append(i[1])
@@ -2065,6 +2068,7 @@ def barplotter(
20652068
plot_data: pd.DataFrame,
20662069
bar_color: str,
20672070
plot_palette_bar: dict,
2071+
color_col: str,
20682072
plot_kwargs: dict,
20692073
barplot_kwargs: dict,
20702074
horizontal: bool
@@ -2088,6 +2092,8 @@ def barplotter(
20882092
Color of the bar.
20892093
plot_palette_bar : dict
20902094
Dictionary of colors used in the bar plot.
2095+
color_col : str
2096+
Column name of the color column.
20912097
plot_kwargs : dict
20922098
Keyword arguments for the plot.
20932099
barplot_kwargs : dict
@@ -2123,6 +2129,8 @@ def barplotter(
21232129
ax=rawdata_axes,
21242130
order=all_plot_groups,
21252131
palette=plot_palette_bar,
2132+
hue=color_col,
2133+
dodge=False,
21262134
zorder=1,
21272135
orient=orient,
21282136
**barplot_kwargs

dabest/plotter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.fi
277277
plot_data = plot_data,
278278
bar_color = bar_color,
279279
plot_palette_bar = plot_palette_bar,
280+
color_col = color_col,
280281
plot_kwargs = plot_kwargs,
281282
barplot_kwargs = barplot_kwargs,
282283
horizontal = horizontal,

0 commit comments

Comments
 (0)