@@ -850,8 +850,8 @@ def sankeydiag(
850850 sankey_ticks = (
851851 [f"{ left } " for left in broadcasted_left ]
852852 if flow
853- else [
854- f"{ left } \n v.s.\n { right } "
853+ else [f" { left } v.s. { right } " if horizontal
854+ else f"{ left } \n v.s.\n { right } "
855855 for left , right in zip (broadcasted_left , right_idx )
856856 ]
857857 )
@@ -917,9 +917,9 @@ def summary_bars_plotter(summary_bars: list, results: object, ax_to_plot: object
917917 else :
918918 summary_xmin , summary_xmax = ax_to_plot .get_xlim ()
919919 summary_bars_colors = (
920- [summary_bars_kwargs .get ('color' )]* (max (ticks_to_plot )+ 1 )
920+ [summary_bars_kwargs .get ('color' )]* int (max (ticks_to_plot )+ 1 )
921921 if summary_bars_kwargs .get ('color' ) is not None
922- else ['black' ]* (max (ticks_to_plot )+ 1 )
922+ else ['black' ]* int (max (ticks_to_plot )+ 1 )
923923 if color_col is not None or (proportional and is_paired ) or is_paired
924924 else list (plot_palette_raw .values ())
925925 )
@@ -932,7 +932,7 @@ def summary_bars_plotter(summary_bars: list, results: object, ax_to_plot: object
932932 summary_ci_low = results .pct_low [summary_index ]
933933 summary_ci_high = results .pct_high [summary_index ]
934934
935- summary_color = summary_bars_colors [ticks_to_plot [summary_index ]]
935+ summary_color = summary_bars_colors [int ( ticks_to_plot [summary_index ]) ]
936936
937937 ax_to_plot .add_patch (mpatches .Rectangle ((summary_xmin ,summary_ci_low ),summary_xmax + 1 ,
938938 summary_ci_high - summary_ci_low , zorder = - 2 , color = summary_color , ** summary_bars_kwargs ))
@@ -981,14 +981,14 @@ def contrast_bars_plotter(results: object, ax_to_plot: object, swarm_plot_ax: o
981981
982982 contrast_means = []
983983 for j , tick in enumerate (ticks_to_plot ):
984- contrast_means .append (results .difference [j ])
984+ contrast_means .append (results .difference [int ( j ) ])
985985
986986 unpacked_idx = [element for innerList in idx for element in innerList ]
987987
988988 contrast_bars_colors = (
989- [contrast_bars_kwargs .get ('color' )] * (max (ticks_to_plot ) + 1 )
989+ [contrast_bars_kwargs .get ('color' )] * int (max (ticks_to_plot ) + 1 )
990990 if contrast_bars_kwargs .get ('color' ) is not None
991- else ['black' ] * (max (ticks_to_plot ) + 1 )
991+ else ['black' ] * int (max (ticks_to_plot ) + 1 )
992992 if color_col is not None or is_paired
993993 else plot_palette_raw
994994 )
@@ -1136,9 +1136,9 @@ def delta_text_plotter(results: object, ax_to_plot: object, swarm_plot_ax: objec
11361136 delta_text_kwargs .pop ('x_location' )
11371137
11381138 delta_text_colors = (
1139- [delta_text_kwargs .get ('color' )]* (max (ticks_to_plot )+ 1 )
1139+ [delta_text_kwargs .get ('color' )]* int (max (ticks_to_plot )+ 1 )
11401140 if delta_text_kwargs .get ('color' ) is not None
1141- else ['black' ]* (max (ticks_to_plot )+ 1 )
1141+ else ['black' ]* int (max (ticks_to_plot )+ 1 )
11421142 if color_col is not None or (proportional and is_paired ) or is_paired
11431143 else plot_palette_raw
11441144 )
@@ -1156,7 +1156,7 @@ def delta_text_plotter(results: object, ax_to_plot: object, swarm_plot_ax: objec
11561156 # Collect the Y-values for the delta text
11571157 Delta_Values = []
11581158 for j , tick in enumerate (ticks_to_plot ):
1159- Delta_Values .append (results .difference [j ])
1159+ Delta_Values .append (results .difference [int ( j ) ])
11601160 if show_delta2 : Delta_Values .append (delta_delta .difference )
11611161 if show_mini_meta : Delta_Values .append (mini_meta_delta .difference )
11621162
@@ -1197,9 +1197,9 @@ def delta_text_plotter(results: object, ax_to_plot: object, swarm_plot_ax: objec
11971197 for x ,y ,t ,tick in zip (delta_text_x_coordinates , delta_text_y_coordinates ,Delta_Values ,ticks_to_plot ):
11981198 Delta_Text = np .format_float_positional (t , precision = 2 , sign = True , trim = "k" , min_digits = 2 )
11991199 idx_selector = (
1200- tick
1200+ int ( tick )
12011201 if type (delta_text_colors ) == list
1202- else unpacked_idx [tick ]
1202+ else unpacked_idx [int ( tick ) ]
12031203 )
12041204 ax_to_plot .text (x , y , Delta_Text , color = delta_text_colors [idx_selector ], zorder = 5 , ** delta_text_kwargs )
12051205
@@ -1349,7 +1349,16 @@ def slopegraph_plotter(dabest_obj, plot_data, xvar, yvar, color_col, plot_palett
13491349 current_pair = pivoted_plot_data .loc [
13501350 :, pd .MultiIndex .from_product ([pivot_values , current_tuple ])
13511351 ].dropna ()
1352+
1353+ # Check for correct pairing
1354+ if len (current_pair ) == 0 :
1355+ raise ValueError ('There are no pairs to plot... check original dataframe for correct ID pairing' )
1356+
1357+ current_pair = pivoted_plot_data .loc [
1358+ :, pd .MultiIndex .from_product ([pivot_values , current_tuple ])
1359+ ]
13521360 grp_count = len (current_tuple )
1361+
13531362 # Iterate through the data for the current tuple.
13541363 for ID , observation in current_pair .iterrows ():
13551364 x_points = [t + 0.15 * jitter * rng .standard_t (df = 6 , size = None ) for t in range (x_start , x_start + grp_count )] # devMJBL
@@ -1545,16 +1554,16 @@ def effect_size_curve_plotter(ticks_to_plot, results, ci_type, contrast_axes, vi
15451554 # Plot the curves
15461555 contrast_xtick_labels = []
15471556 for j , tick in enumerate (ticks_to_plot ):
1548- current_group = results .test [j ]
1549- current_control = results .control [j ]
1550- current_bootstrap = results .bootstraps [j ]
1551- current_effsize = results .difference [j ]
1557+ current_group = results .test [int ( j ) ]
1558+ current_control = results .control [int ( j ) ]
1559+ current_bootstrap = results .bootstraps [int ( j ) ]
1560+ current_effsize = results .difference [int ( j ) ]
15521561 if ci_type == "bca" :
1553- current_ci_low = results .bca_low [j ]
1554- current_ci_high = results .bca_high [j ]
1562+ current_ci_low = results .bca_low [int ( j ) ]
1563+ current_ci_high = results .bca_high [int ( j ) ]
15551564 else :
1556- current_ci_low = results .pct_low [j ]
1557- current_ci_high = results .pct_high [j ]
1565+ current_ci_low = results .pct_low [int ( j ) ]
1566+ current_ci_high = results .pct_high [int ( j ) ]
15581567
15591568 # Create the violinplot.
15601569 # New in v0.2.6: drop negative infinities before plotting.
@@ -2195,6 +2204,8 @@ def __init__(
21952204 h = (ax .get_position ().ymax - ax .get_position ().ymin ) * figh
21962205 ax_xspan = ax .get_xlim ()[1 ] - ax .get_xlim ()[0 ]
21972206 ax_yspan = ax .get_ylim ()[1 ] - ax .get_ylim ()[0 ]
2207+ if horizontal :
2208+ ax_xspan , ax_yspan = ax_yspan , ax_xspan
21982209
21992210 # increases jitter distance based on number of swarms that is going to be drawn
22002211 jitter = jitter * (1 + 0.05 * (math .log (ax_xspan )))
0 commit comments