@@ -949,14 +949,14 @@ def summary_bars_plotter(summary_bars: list, results: object, ax_to_plot: object
949949 ax_to_plot .add_patch (mpatches .Rectangle (
950950 (summary_ci_low , starting_location ),
951951 summary_ci_high - summary_ci_low , summary_ymin + 1 ,
952- zorder = - 2 , color = summary_color ,
952+ color = summary_color ,
953953 ** summary_bars_kwargs )
954954 )
955955 else :
956956 ax_to_plot .add_patch (mpatches .Rectangle (
957957 (starting_location , summary_ci_low ),
958958 summary_xmax + 1 , summary_ci_high - summary_ci_low ,
959- zorder = - 2 , color = summary_color ,
959+ color = summary_color ,
960960 ** summary_bars_kwargs )
961961 )
962962
@@ -1023,13 +1023,11 @@ def contrast_bars_plotter(results: object, ax_to_plot: object, swarm_plot_ax: o
10231023 if type (contrast_bars_colors ) == list
10241024 else unpacked_idx [int (contrast_bars_x )]
10251025 )
1026- ax_to_plot .add_patch (mpatches .Rectangle ((0 ,contrast_bars_x - 0.5 ),contrast_bars_y , 0.5 , zorder = - 10 , color = contrast_bars_colors [idx_selector ], ** contrast_bars_kwargs ))
1026+ ax_to_plot .add_patch (mpatches .Rectangle ((0 ,contrast_bars_x - 0.5 ),contrast_bars_y , 0.5 , color = contrast_bars_colors [idx_selector ], ** contrast_bars_kwargs ))
10271027
1028- if show_mini_meta :
1029- ax_to_plot .add_patch (mpatches .Rectangle ((0 , max (swarm_plot_ax .get_yticks ())- 0.5 ), mini_meta_delta .difference , 0.5 , zorder = - 10 , color = 'black' , ** contrast_bars_kwargs ))
1030-
1031- if show_delta2 :
1032- ax_to_plot .add_patch (mpatches .Rectangle ((0 , max (swarm_plot_ax .get_yticks ())- 0.5 ), delta_delta .difference , 0.5 , zorder = - 10 , color = 'black' , ** contrast_bars_kwargs ))
1028+ if show_mini_meta or show_delta2 :
1029+ diff = mini_meta_delta .difference if show_mini_meta else delta_delta .difference
1030+ ax_to_plot .add_patch (mpatches .Rectangle ((0 , max (swarm_plot_ax .get_yticks ())- 0.5 ), diff , 0.5 , color = 'black' , ** contrast_bars_kwargs ))
10331031
10341032 else :
10351033 for contrast_bars_x ,contrast_bars_y in zip (ticks_to_plot , contrast_means ):
@@ -1038,13 +1036,11 @@ def contrast_bars_plotter(results: object, ax_to_plot: object, swarm_plot_ax: o
10381036 if type (contrast_bars_colors ) == list
10391037 else unpacked_idx [int (contrast_bars_x )]
10401038 )
1041- ax_to_plot .add_patch (mpatches .Rectangle ((contrast_bars_x - 0.25 ,0 ),0.5 , contrast_bars_y , zorder = - 1 , color = contrast_bars_colors [idx_selector ], ** contrast_bars_kwargs ))
1039+ ax_to_plot .add_patch (mpatches .Rectangle ((contrast_bars_x - 0.25 ,0 ),0.5 , contrast_bars_y , color = contrast_bars_colors [idx_selector ], ** contrast_bars_kwargs ))
10421040
1043- if show_mini_meta :
1044- ax_to_plot .add_patch (mpatches .Rectangle ((max (swarm_plot_ax .get_xticks ())+ 2 - 0.25 ,0 ),0.5 , mini_meta_delta .difference , zorder = - 1 , color = 'black' , ** contrast_bars_kwargs ))
1045-
1046- if show_delta2 :
1047- ax_to_plot .add_patch (mpatches .Rectangle ((max (swarm_plot_ax .get_xticks ())+ 2 - 0.25 ,0 ),0.5 , delta_delta .difference , zorder = - 1 , color = 'black' , ** contrast_bars_kwargs ))
1041+ if show_mini_meta or show_delta2 :
1042+ diff = mini_meta_delta .difference if show_mini_meta else delta_delta .difference
1043+ ax_to_plot .add_patch (mpatches .Rectangle ((max (swarm_plot_ax .get_xticks ())+ 2 - 0.25 ,0 ),0.5 , diff , color = 'black' , ** contrast_bars_kwargs ))
10481044
10491045 ax_to_plot .set_xlim (og_xlim )
10501046 ax_to_plot .set_ylim (og_ylim )
@@ -1103,7 +1099,7 @@ def swarm_bars_plotter(plot_data: object, xvar: str, yvar: str, ax: object,
11031099 else unpacked_idx [swarm_bars_x ]
11041100 )
11051101 ax .add_patch (mpatches .Rectangle ((swarm_bars_x - 0.25 ,0 ), 0.5 , swarm_bars_y ,
1106- zorder = - 1 , color = swarm_bars_colors [idx_selector ],** swarm_bars_kwargs ))
1102+ color = swarm_bars_colors [idx_selector ],** swarm_bars_kwargs ))
11071103
11081104 ax .set_xlim (og_xlim )
11091105 ax .set_ylim (og_ylim )
@@ -1344,15 +1340,12 @@ def slopegraph_plotter(dabest_obj, plot_data, xvar, yvar, color_col, plot_palett
13441340 """
13451341 # Jitter Kwargs
13461342 # With help from devMJBL
1347- jitter = slopegraph_kwargs [ "jitter" ]
1343+ jitter = slopegraph_kwargs . pop ( "jitter" )
13481344 if jitter >= 1 :
13491345 err0 = "Jitter value is too high. Defaulting to 1."
13501346 warnings .warn (err0 )
13511347 jitter = 1
1352- rng = np .random .default_rng (slopegraph_kwargs ["jitter_seed" ])
1353- for key in ["jitter" , "jitter_seed" ]:
1354- if key in slopegraph_kwargs :
1355- slopegraph_kwargs .pop (key )
1348+ rng = np .random .default_rng (slopegraph_kwargs .pop ("jitter_seed" ))
13561349
13571350 # Pivot the long (melted) data.
13581351 if color_col is None :
@@ -1539,7 +1532,8 @@ def plot_minimeta_or_deltadelta_violins(show_mini_meta, effectsize_df, ci_type,
15391532
15401533def effect_size_curve_plotter (ticks_to_plot , results , ci_type , contrast_axes , violinplot_kwargs , halfviolin_alpha ,
15411534 ytick_color , bootstraps_color_by_group , plot_palette_contrast ,
1542- horizontal , es_marker_kwargs , es_errorbar_kwargs ):
1535+ horizontal , es_marker_kwargs , es_errorbar_kwargs ,
1536+ idx , is_paired , es_paired_lines , es_paired_lines_kwargs ):
15431537 """
15441538 Add effect size curves to the contrast plot.
15451539
@@ -1571,6 +1565,14 @@ def effect_size_curve_plotter(ticks_to_plot, results, ci_type, contrast_axes, vi
15711565 Keyword arguments for the effectsize marker.
15721566 es_errorbar_kwargs: dict
15731567 Keyword arguments for the effectsize errorbar.
1568+ idx : list
1569+ List of indices of the raw groups.
1570+ is_paired : bool
1571+ Whether the data is paired.
1572+ es_paired_lines : bool
1573+ Whether to add lines for repeated measures data.
1574+ es_paired_lines_kwargs : dict
1575+ Keyword arguments for the repeated measures lines.
15741576 """
15751577
15761578 # Plot the curves
@@ -1618,21 +1620,56 @@ def effect_size_curve_plotter(ticks_to_plot, results, ci_type, contrast_axes, vi
16181620 contrast_axes .plot (
16191621 effsize_x ,
16201622 effsize_y ,
1621- # color=ytick_color,
16221623 ** es_marker_kwargs
16231624 )
16241625
16251626 # Plot the confidence interval.
16261627 contrast_axes .plot (
16271628 ci_x ,
16281629 ci_y ,
1629- # color=ytick_color,
16301630 ** es_errorbar_kwargs
16311631 )
16321632
16331633 contrast_xtick_labels .append (
16341634 "{}\n minus\n {}" .format (current_group , current_control )
16351635 )
1636+
1637+ # Add lines for repeated measures data
1638+ if is_paired and es_paired_lines :
1639+ temp_num = 0
1640+ lines_to_plot_list = []
1641+
1642+ for group in idx :
1643+ new_group = []
1644+ if len (group ) >= 2 :
1645+ new_group .append (temp_num )
1646+ for i in range (1 , len (group )):
1647+ new_group .append (temp_num + i )
1648+ temp_num += len (group )
1649+ lines_to_plot_list .append (new_group )
1650+
1651+ for group in lines_to_plot_list :
1652+ if len (group ) > 0 :
1653+ mean_diffs_for_lines = []
1654+ for ticks in group :
1655+ if ticks in ticks_to_plot :
1656+ mean_diffs_for_lines .append (results .loc [ticks_to_plot .index (ticks )]["difference" ])
1657+ else :
1658+ mean_diffs_for_lines .append (int (0 ))
1659+
1660+ if horizontal :
1661+ contrast_axes .plot (
1662+ mean_diffs_for_lines ,
1663+ group ,
1664+ ** es_paired_lines_kwargs
1665+ )
1666+ else :
1667+ contrast_axes .plot (
1668+ group ,
1669+ mean_diffs_for_lines ,
1670+ ** es_paired_lines_kwargs
1671+ )
1672+
16361673 return current_group , current_control , current_effsize , contrast_xtick_labels
16371674
16381675def gridkey_plotter (is_paired , idx , all_plot_groups , gridkey_rows , rawdata_axes , contrast_axes ,
0 commit comments