@@ -1042,7 +1042,7 @@ def swarm_contrast_bar_plotter(
10421042 if horizontal :
10431043 ax_to_plot .add_patch (mpatches .Rectangle ((0 , max (axes [0 ].get_yticks ())- 0.5 ), diff , 0.5 , color = 'black' , ** bar_kwargs ))
10441044 else :
1045- ax_to_plot .add_patch (mpatches .Rectangle ((max (axes [0 ].get_xticks ())+ 2 - 0.25 , 0 ), 0.5 , diff , color = 'black' , ** bar_kwargs ))
1045+ ax_to_plot .add_patch (mpatches .Rectangle ((max (axes [0 ].get_xticks ())+ 1 - 0.25 , 0 ), 0.5 , diff , color = 'black' , ** bar_kwargs ))
10461046
10471047 ax_to_plot .set_xlim (og_xlim )
10481048 ax_to_plot .set_ylim (og_ylim )
@@ -1144,8 +1144,8 @@ def delta_text_plotter(
11441144 X_Adjust = 0.48 if delta_text_x_location == 'right' else - 0.38
11451145 X_Adjust += delta_text_x_adjustment
11461146 delta_text_x_coordinates = [x + X_Adjust for x in delta_text_x_coordinates ]
1147- if show_mini_meta : delta_text_x_coordinates .append (max (swarm_plot_ax .get_xticks ())+ 2 + X_Adjust )
1148- if show_delta2 : delta_text_x_coordinates .append (max (swarm_plot_ax .get_xticks ())+ 2 - 0.35 )
1147+ if show_mini_meta : delta_text_x_coordinates .append (max (swarm_plot_ax .get_xticks ())+ 1 + X_Adjust )
1148+ if show_delta2 : delta_text_x_coordinates .append (max (swarm_plot_ax .get_xticks ())+ 1 + X_Adjust )
11491149 if show_mini_meta or show_delta2 : ticks_to_plot .append (max (ticks_to_plot )+ 1 )
11501150
11511151 # Collect the Y-coordinates for the delta text
@@ -1390,6 +1390,7 @@ def plot_minimeta_or_deltadelta_violins(
13901390 show_delta2 : bool ,
13911391 plot_kwargs : dict ,
13921392 horizontal : bool ,
1393+ show_pairs : bool ,
13931394 es_marker_kwargs : dict ,
13941395 es_errorbar_kwargs : dict
13951396 ):
@@ -1424,6 +1425,8 @@ def plot_minimeta_or_deltadelta_violins(
14241425 Keyword arguments for the plot.
14251426 horizontal : bool
14261427 If the plot is horizontal.
1428+ show_pairs : bool
1429+ Whether the data is paired and shown in pairs.
14271430 es_marker_kwargs: dict
14281431 Keyword arguments for the effectsize marker.
14291432 es_errorbar_kwargs: dict
@@ -1450,7 +1453,8 @@ def extract_curve_data(dabest_object):
14501453 effsize_x , effsize_y = difference , [position ]
14511454 ci_x , ci_y = [ci_low , ci_high ], [position , position ]
14521455 else :
1453- position = max (rawdata_axes .get_xticks ()) + 2
1456+ # position = max(rawdata_axes.get_xticks()) + 2
1457+ position = max (rawdata_axes .get_xticks ()) + 1
14541458 half = "right"
14551459 effsize_x , effsize_y = [position ], difference
14561460 ci_x , ci_y = [position , position ], [ci_low , ci_high ]
@@ -1489,18 +1493,21 @@ def extract_curve_data(dabest_object):
14891493
14901494 else :
14911495 if show_mini_meta :
1492- contrast_xtick_labels .extend (["" , "Weighted Delta" ])
1496+ if show_pairs :
1497+ contrast_xtick_labels .extend (["Weighted\n Delta" ])
1498+ else :
1499+ contrast_xtick_labels .extend (["Weighted Delta" ])
14931500 elif effect_size == "hedges_g" :
1494- contrast_xtick_labels .extend (["" , " Deltas' g" ])
1501+ contrast_xtick_labels .extend (["Deltas' g" ])
14951502 else :
1496- contrast_xtick_labels .extend (["" , " Delta-Delta" ])
1503+ contrast_xtick_labels .extend (["Delta-Delta" ])
14971504
14981505 # Create the delta-delta axes.
14991506 if show_delta2 and not horizontal :
15001507 if plot_kwargs ["delta2_label" ] is not None :
15011508 delta2_label = plot_kwargs ["delta2_label" ]
15021509 elif effect_size == "mean_diff" :
1503- delta2_label = "Delta - Delta"
1510+ delta2_label = "Delta- Delta"
15041511 else :
15051512 delta2_label = "Deltas' g"
15061513 fontsize_delta2label = plot_kwargs ["fontsize_delta2label" ]
@@ -1880,23 +1887,45 @@ def gridkey_plotter(
18801887 gridkey_rows = added_group_name + gridkey_rows
18811888 table_cellcols = [["" ]* len (table_cellcols [0 ])] + table_cellcols
18821889
1883- for group_idx , group_vals in enumerate (table_cellcols ):
1884- if group_idx == 0 :
1885- added_group = ['' , gridkey_marker ]
1886- elif gridkey_show_es and (group_idx == len (table_cellcols )- 1 ) and not horizontal :
1887- added_delta_effectsize = delta_delta .difference if show_delta2 else mini_meta .difference
1888- added_delta_effectsize_str = np .format_float_positional (
1889- added_delta_effectsize ,
1890- precision = 2 ,
1891- sign = True ,
1892- trim = "k" ,
1893- min_digits = 2 ,
1894- )
1895- added_group = ['-' , added_delta_effectsize_str ]
1896- else :
1897- added_group = ['' , '' ]
1898- for n in added_group :
1899- group_vals .append (n )
1890+ if not horizontal and show_delta2 :
1891+ extra_table_cellcols = [[] for i in range (len (table_cellcols ))]
1892+
1893+ for group_idx , group_vals in enumerate (extra_table_cellcols ):
1894+ if group_idx == 0 :
1895+ added_group = [gridkey_marker ]
1896+ elif gridkey_show_es and (group_idx == len (extra_table_cellcols )- 1 ) and not horizontal :
1897+ added_delta_effectsize = delta_delta .difference
1898+ added_delta_effectsize_str = np .format_float_positional (
1899+ added_delta_effectsize ,
1900+ precision = 2 ,
1901+ sign = True ,
1902+ trim = "k" ,
1903+ min_digits = 2 ,
1904+ )
1905+ added_group = [added_delta_effectsize_str ]
1906+ else :
1907+ added_group = ['' ]
1908+ for n in added_group :
1909+ group_vals .append (n )
1910+
1911+ elif horizontal or show_mini_meta :
1912+ for group_idx , group_vals in enumerate (table_cellcols ):
1913+ if group_idx == 0 :
1914+ added_group = [gridkey_marker ] if not horizontal else [" " , gridkey_marker ]
1915+ elif gridkey_show_es and (group_idx == len (table_cellcols )- 1 ) and not horizontal :
1916+ added_delta_effectsize = delta_delta .difference if show_delta2 else mini_meta .difference
1917+ added_delta_effectsize_str = np .format_float_positional (
1918+ added_delta_effectsize ,
1919+ precision = 2 ,
1920+ sign = True ,
1921+ trim = "k" ,
1922+ min_digits = 2 ,
1923+ )
1924+ added_group = [added_delta_effectsize_str ] if not horizontal else ['' , added_delta_effectsize_str ]
1925+ else :
1926+ added_group = ['' ] if not horizontal else ['' , '' ]
1927+ for n in added_group :
1928+ group_vals .append (n )
19001929
19011930 # Create the table object
19021931 if horizontal :
@@ -1936,18 +1965,60 @@ def gridkey_plotter(
19361965 )
19371966 else :
19381967 # Plot the table for vertical format
1939- gridkey = ax_to_plot .table (
1940- cellText = table_cellcols ,
1941- rowLabels = gridkey_rows ,
1942- cellLoc = "center" ,
1943- bbox = [
1944- 0 ,
1945- - len (gridkey_rows ) * 0.1 - 0.05 ,
1946- 1 ,
1947- len (gridkey_rows ) * 0.1 ,
1948- ],
1949- ** {"alpha" : 0.5 }
1950- )
1968+ if show_mini_meta :
1969+ gridkey = ax_to_plot .table (
1970+ cellText = table_cellcols ,
1971+ rowLabels = gridkey_rows ,
1972+ cellLoc = "center" ,
1973+ bbox = [
1974+ 0 ,
1975+ - len (gridkey_rows ) * 0.1 - 0.05 ,
1976+ 1 ,
1977+ len (gridkey_rows ) * 0.1 ,
1978+ ],
1979+ ** {"alpha" : 0.5 }
1980+ )
1981+
1982+ elif show_delta2 :
1983+ gridkey = ax_to_plot .table (
1984+ cellText = table_cellcols ,
1985+ rowLabels = gridkey_rows ,
1986+ cellLoc = "center" ,
1987+ bbox = [
1988+ 0 ,
1989+ - len (gridkey_rows ) * 0.1 - 0.05 ,
1990+ 0.75 ,
1991+ len (gridkey_rows ) * 0.1 ,
1992+ ],
1993+ ** {"alpha" : 0.5 }
1994+ )
1995+
1996+ extra_gridkey = ax_to_plot .table (
1997+ cellText = extra_table_cellcols ,
1998+ cellLoc = "center" ,
1999+ bbox = [
2000+ 0.78 ,
2001+ - len (gridkey_rows ) * 0.1 - 0.05 ,
2002+ 0.15 ,
2003+ len (gridkey_rows ) * 0.1 ,
2004+ ],
2005+ ** {"alpha" : 0.5 }
2006+ )
2007+
2008+ else :
2009+ gridkey = ax_to_plot .table (
2010+ cellText = table_cellcols ,
2011+ rowLabels = gridkey_rows ,
2012+ cellLoc = "center" ,
2013+ bbox = [
2014+ 0 ,
2015+ - len (gridkey_rows ) * 0.1 - 0.05 ,
2016+ 1 ,
2017+ len (gridkey_rows ) * 0.1 ,
2018+ ],
2019+ ** {"alpha" : 0.5 }
2020+ )
2021+
19512022 # modifies row label cells
19522023 for cell in gridkey ._cells :
19532024 if cell [1 ] == - 1 :
0 commit comments