@@ -59,16 +59,19 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
5959 ytick_color = plt .rcParams ["ytick.color" ]
6060 axes_facecolor = plt .rcParams ['axes.facecolor' ]
6161
62- dabest_obj = EffectSizeDataFrame .dabest_obj
63- plot_data = EffectSizeDataFrame ._plot_data
64- xvar = EffectSizeDataFrame .xvar
65- yvar = EffectSizeDataFrame .yvar
66- is_paired = EffectSizeDataFrame .is_paired
67- delta2 = EffectSizeDataFrame .delta2
62+ dabest_obj = EffectSizeDataFrame .dabest_obj
63+ plot_data = EffectSizeDataFrame ._plot_data
64+ xvar = EffectSizeDataFrame .xvar
65+ yvar = EffectSizeDataFrame .yvar
66+ is_paired = EffectSizeDataFrame .is_paired
67+ delta2 = EffectSizeDataFrame .delta2
68+ effect_size = EffectSizeDataFrame .effect_size
6869
6970 all_plot_groups = dabest_obj ._all_plot_groups
7071 idx = dabest_obj .idx
7172
73+ if effect_size != "mean_diff" :
74+ delta2 = False
7275
7376
7477
@@ -93,6 +96,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
9396 show_pairs = plot_kwargs ["show_pairs" ]
9497
9598
99+
96100 # Set default kwargs first, then merge with user-dictated ones.
97101 default_swarmplot_kwargs = {'size' : plot_kwargs ["raw_marker_size" ]}
98102 if plot_kwargs ["swarmplot_kwargs" ] is None :
@@ -102,6 +106,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
102106 plot_kwargs ["swarmplot_kwargs" ])
103107
104108
109+
105110 # Violinplot kwargs.
106111 default_violinplot_kwargs = {'widths' :0.5 , 'vert' :True ,
107112 'showextrema' :False , 'showmedians' :False }
@@ -112,6 +117,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
112117 plot_kwargs ["violinplot_kwargs" ])
113118
114119
120+
115121 # slopegraph kwargs.
116122 default_slopegraph_kwargs = {'lw' :1 , 'alpha' :0.5 }
117123 if plot_kwargs ["slopegraph_kwargs" ] is None :
@@ -121,6 +127,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
121127 plot_kwargs ["slopegraph_kwargs" ])
122128
123129
130+
124131 # Zero reference-line kwargs.
125132 default_reflines_kwargs = {'linestyle' :'solid' , 'linewidth' :0.75 ,
126133 'zorder' : 2 ,
@@ -218,6 +225,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
218225 plot_palette_contrast = dict (zip (names , contrast_colors ))
219226
220227
228+
221229 # Infer the figsize.
222230 fig_size = plot_kwargs ["fig_size" ]
223231 if fig_size is None :
@@ -322,6 +330,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
322330 contrast_axes .set_frame_on (False )
323331 if delta2 :
324332 delta_axes .set_frame_on (False )
333+
325334 redraw_axes_kwargs = {'colors' : ytick_color ,
326335 'facecolors' : ytick_color ,
327336 'lw' : 1 ,
@@ -460,8 +469,6 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
460469 ticks_to_plot = np .arange (1 , len (temp_all_plot_groups ), 2 ).tolist ()
461470 ticks_to_skip_contrast = np .cumsum ([(len (t )- 1 )* 2 for t in idx ])[:- 1 ].tolist ()
462471 ticks_to_skip_contrast .insert (0 , 0 )
463- if delta2 :
464- ticks_to_skip_contrast .append (max (ticks_to_skip_contrast )+ 2 )
465472 else :
466473 ticks_to_skip = np .cumsum ([len (t ) for t in idx ])[:- 1 ].tolist ()
467474 ticks_to_skip .insert (0 , 0 )
@@ -575,6 +582,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
575582 if float_contrast is True :
576583 contrast_axes .set_xlim (0.5 , 1.5 )
577584 elif delta2 :
585+ # Increase the xlim of raw data by 2; set xlim and label xlim
586+ # of the delta-delta plot.
578587 contrast_axes .set_xlim (rawdata_axes .get_xlim ())
579588 temp = rawdata_axes .get_xlim ()
580589 rawdata_axes .set_xlim (temp [0 ], temp [1 ]+ 2 )
@@ -769,7 +778,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
769778 contrast_ylim_high , contrast_ylim_low = contrast_axes_ylim
770779 if contrast_ylim_low < 0 < contrast_ylim_high :
771780 contrast_axes .axhline (y = 0 , ** reflines_kwargs )
772- delta_axes .axhline (y = 0 , xmin = 0.25 , xmax = 1.5 , ** reflines_kwargs )
781+ if delta2 :
782+ delta_axes .axhline (y = 0 , xmin = 0.25 , xmax = 1.5 , ** reflines_kwargs )
773783
774784
775785 if delta2 and plot_kwargs ['delta_ylim' ] is not None :
@@ -789,7 +799,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
789799 delta_axes .set_ylim (low , high )
790800 else :
791801 delta_axes .set_ylim (custom_delta_ylim )
792- if delta2 :
802+ if delta2 and plot_kwargs [ 'delta_ylim' ] is None and plot_kwargs [ 'contrast_ylim' ] is None :
793803 ylim_contrast = contrast_axes .get_ylim ()
794804 ylim_delta = delta_axes .get_ylim ()
795805 ylim = (min (ylim_contrast [0 ], ylim_delta [0 ]), max (ylim_contrast [1 ], ylim_delta [1 ]))
@@ -814,8 +824,6 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
814824 del redraw_axes_kwargs ['y' ]
815825
816826 temp_length = [(len (i )- 1 )* 2 - 1 for i in idx ]
817- if delta2 :
818- temp_length .append (1 )
819827 rightend_ticks_contrast = np .array (temp_length ) + np .array (ticks_to_skip_contrast )
820828 for ax in [contrast_axes ]:
821829 sns .despine (ax = ax , bottom = True )
0 commit comments