@@ -128,7 +128,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
128128
129129 # Sankey Diagram kwargs
130130 default_sankey_kwargs = {"width" : 0.5 , "align" : "center" ,
131- "alpha" : 0.65 , "rightColor" : False }
131+ "alpha" : 0.4 , "rightColor" : False ,
132+ "bar_width" :0.1 }
132133 if plot_kwargs ["sankey_kwargs" ] is None :
133134 sankey_kwargs = default_sankey_kwargs
134135 else :
@@ -253,7 +254,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
253254 # For Sankey Diagram plot, no need to worry about the color, each bar will have the same two colors
254255 # default color palette will be set to "hls"
255256 plot_palette_sankey = None
256-
257+
257258 else :
258259 swarm_colors = [sns .desaturate (c , swarm_desat ) for c in unsat_colors ]
259260 plot_palette_raw = dict (zip (names , swarm_colors ))
@@ -388,16 +389,9 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
388389 temp_all_plot_groups = []
389390 for i in temp_idx :
390391 temp_all_plot_groups .extend (list (i ))
391- # TODO - Figure out how to draw sankey diagram for baseline paired.
392- # sankey_control_group = [all_plot_groups[0]]
393- # sankey_test_group = all_plot_groups.copy()
394- # sankey_test_group.pop(0)
395392 else :
396393 temp_idx = idx
397394 temp_all_plot_groups = all_plot_groups
398- sankey_control_group = [all_plot_groups [0 ]]
399- sankey_test_group = all_plot_groups .copy ()
400- sankey_test_group .pop (0 )
401395
402396 if proportional == False :
403397 # Plot the raw data as a slopegraph.
@@ -451,6 +445,17 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
451445 if err_color == None :
452446 err_color = "black"
453447
448+ if show_pairs is True :
449+ if is_paired == "baseline" :
450+ sankey_control_group = []
451+ sankey_test_group = []
452+ for i in temp_idx :
453+ sankey_control_group .append (i [0 ])
454+ sankey_test_group .append (i [1 ])
455+ else :
456+ sankey_control_group = all_plot_groups [:- 1 ]
457+ sankey_test_group = all_plot_groups [1 :]
458+
454459 # Replace the paired proportional plot with sankey diagram
455460 sankey = sankeydiag (plot_data , xvar = xvar , yvar = yvar ,
456461 left_idx = sankey_control_group ,
@@ -562,17 +567,24 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
562567 rawdata_axes .legend ().set_visible (False )
563568
564569
565- #TODO: There is a bug for setting `is_paired` to be "baseline": Cannot achieve multiple tests vs. one control.
570+ #TODO: When setting 'baseline', the plot is shrinked together and the contrast axes position should be fixed
566571 # Plot effect sizes and bootstraps.
567572 # Take note of where the `control` groups are.
568573 if is_paired == "baseline" and show_pairs == True :
569- ticks_to_skip = np .arange (0 , len (temp_all_plot_groups ), 2 ).tolist ()
570- ticks_to_plot = np .arange (1 , len (temp_all_plot_groups ), 2 ).tolist ()
571- ticks_to_skip_contrast = np .cumsum ([(len (t )- 1 )* 2 for t in idx ])[:- 1 ].tolist ()
572- ticks_to_skip_contrast .insert (0 , 0 )
574+ if proportional == True :
575+ ticks_to_skip = []
576+ ticks_to_plot = np .arange (0 , len (temp_all_plot_groups )/ 2 ).tolist ()
577+ else :
578+ ticks_to_skip = np .arange (0 , len (temp_all_plot_groups ), 2 ).tolist ()
579+ ticks_to_plot = np .arange (1 , len (temp_all_plot_groups ), 2 ).tolist ()
580+ ticks_to_skip_contrast = np .cumsum ([(len (t )- 1 )* 2 for t in idx ])[:- 1 ].tolist ()
581+ ticks_to_skip_contrast .insert (0 , 0 )
573582 else :
574- ticks_to_skip = np .cumsum ([len (t ) for t in idx ])[:- 1 ].tolist ()
575- ticks_to_skip .insert (0 , 0 )
583+ if proportional == True :
584+ ticks_to_skip = [len (sankey_control_group )]
585+ else :
586+ ticks_to_skip = np .cumsum ([len (t ) for t in idx ])[:- 1 ].tolist ()
587+ ticks_to_skip .insert (0 , 0 )
576588
577589 # Then obtain the ticks where we have to plot the effect sizes.
578590 ticks_to_plot = [t for t in range (0 , len (all_plot_groups ))
@@ -586,6 +598,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
586598 results = EffectSizeDataFrame .results
587599 contrast_xtick_labels = []
588600
601+ #TODO: Why is there always two plots showing together
602+
589603 #TODO: The contrast axes xticks is still to be fixed
590604 for j , tick in enumerate (ticks_to_plot ):
591605 current_group = results .test [j ]
@@ -694,9 +708,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
694708 contrast_axes .set_xlim (rawdata_axes .get_xlim ())
695709
696710 # Properly label the contrast ticks.
697- if not (proportional == True and is_paired is not None ):
698- for t in ticks_to_skip :
699- contrast_xtick_labels .insert (t , "" )
711+ for t in ticks_to_skip :
712+ contrast_xtick_labels .insert (t , "" )
700713 contrast_axes .set_xticklabels (contrast_xtick_labels )
701714
702715 if bootstraps_color_by_group is False :
0 commit comments