@@ -14,8 +14,8 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
1414 **plot_kwargs:
1515 color_col=None
1616 raw_marker_size=6, es_marker_size=9,
17- swarm_label=None, contrast_label=None, delta_label =None,
18- swarm_ylim=None, contrast_ylim=None,
17+ swarm_label=None, contrast_label=None, delta2_label =None,
18+ swarm_ylim=None, contrast_ylim=None, delta2_ylim=None,
1919 custom_palette=None, swarm_desat=0.5, halfviolin_desat=1,
2020 halfviolin_alpha=0.8,
2121 float_contrast=True,
@@ -66,6 +66,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
6666 yvar = EffectSizeDataFrame .yvar
6767 is_paired = EffectSizeDataFrame .is_paired
6868 delta2 = EffectSizeDataFrame .delta2
69+ mini_meta = EffectSizeDataFrame .mini_meta
6970 effect_size = EffectSizeDataFrame .effect_size
7071
7172 all_plot_groups = dabest_obj ._all_plot_groups
@@ -79,8 +80,14 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
7980 show_delta2 = plot_kwargs ["show_delta2" ]
8081
8182
83+ if effect_size != "mean_diff" or not mini_meta :
84+ show_mini_meta = False
85+ else :
86+ show_mini_meta = plot_kwargs ["show_mini_meta" ]
8287
83-
88+ if show_delta2 and show_mini_meta :
89+ err0 = "`show_delta2` and `show_mini_meta` cannot be True at the same time."
90+ raise ValueError (err0 )
8491
8592 # Disable Gardner-Altman plotting if any of the idxs comprise of more than
8693 # two groups or if it is a delta-delta plot.
@@ -92,7 +99,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
9299 if effect_size_type in ['cliffs_delta' ]:
93100 float_contrast = False
94101
95- if show_delta2 :
102+ if show_delta2 or show_mini_meta :
96103 float_contrast = False
97104
98105 if not is_paired :
@@ -236,7 +243,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
236243 if fig_size is None :
237244 all_groups_count = np .sum ([len (i ) for i in dabest_obj .idx ])
238245 # Increase the width for delta-delta graph
239- if show_delta2 :
246+ if show_delta2 or show_mini_meta :
240247 all_groups_count += 2
241248 if is_paired and show_pairs is True :
242249 frac = 0.75
@@ -527,9 +534,42 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
527534 current_control ))
528535
529536
537+ # Plot mini-meta violin
538+ if show_mini_meta :
539+ mini_meta_delta = EffectSizeDataFrame .mini_meta_delta
540+ weighted_deltas = mini_meta_delta .weighted_diff_from_boots
541+ difference = mini_meta_delta .difference
542+ ci_low = mini_meta_delta .bca_low
543+ ci_high = mini_meta_delta .bca_high
544+
545+ #Create the violinplot.
546+ #New in v0.2.6: drop negative infinities before plotting.
547+ position = max (rawdata_axes .get_xticks ())+ 2
548+ v = contrast_axes .violinplot (weighted_deltas [~ np .isinf (weighted_deltas )],
549+ positions = [position ],
550+ ** violinplot_kwargs )
551+
552+ fc = "grey"
553+
554+ halfviolin (v , fill_color = fc , alpha = halfviolin_alpha )
555+
556+ # Plot the effect size.
557+ contrast_axes .plot ([position ], difference , marker = 'o' ,
558+ color = ytick_color ,
559+ markersize = es_marker_size )
560+ # Plot the confidence interval.
561+ contrast_axes .plot ([position , position ],
562+ [ci_low , ci_high ],
563+ linestyle = "-" ,
564+ color = ytick_color ,
565+ linewidth = group_summary_kwargs ['lw' ])
566+
567+ contrast_xtick_labels .extend (["" ,"Weighted delta" ])
568+
569+
530570 # Make sure the contrast_axes x-lims match the rawdata_axes xlims,
531571 # and add an extra violinplot tick for delta-delta plot.
532- if not show_delta2 :
572+ if show_delta2 is False and show_mini_meta is False :
533573 contrast_axes .set_xticks (rawdata_axes .get_xticks ())
534574 else :
535575 temp = rawdata_axes .get_xticks ()
@@ -543,7 +583,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
543583
544584 if float_contrast is True :
545585 contrast_axes .set_xlim (0.5 , 1.5 )
546- elif show_delta2 :
586+ elif show_delta2 or show_mini_meta :
547587 # Increase the xlim of raw data by 2
548588 temp = rawdata_axes .get_xlim ()
549589 if show_pairs :
@@ -712,8 +752,20 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
712752 # For Cumming Plots only.
713753
714754 # Set custom contrast_ylim, if it was specified.
715- if plot_kwargs ['contrast_ylim' ] is not None :
716- custom_contrast_ylim = plot_kwargs ['contrast_ylim' ]
755+ if plot_kwargs ['contrast_ylim' ] is not None or (plot_kwargs ['delta2_ylim' ] is not None and show_delta2 ):
756+
757+ if plot_kwargs ['contrast_ylim' ] is not None :
758+ custom_contrast_ylim = plot_kwargs ['contrast_ylim' ]
759+ if plot_kwargs ['delta2_ylim' ] is not None and show_delta2 :
760+ custom_delta2_ylim = plot_kwargs ['delta2_ylim' ]
761+ if custom_contrast_ylim != custom_deltas_ylim :
762+ err1 = "Please check if `contrast_ylim` and `delta2_ylim` are assigned"
763+ err2 = "with same values."
764+ raise ValueError (err1 + err2 )
765+ else :
766+ custom_delta2_ylim = plot_kwargs ['delta2_ylim' ]
767+ custom_contrast_ylim = custom_delta2_ylim
768+
717769
718770 if len (custom_contrast_ylim ) != 2 :
719771 err1 = "Please check `contrast_ylim` consists of "
@@ -791,7 +843,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
791843 ax .set_ylim (ylim )
792844 del redraw_axes_kwargs ['y' ]
793845
794- if show_delta2 is True :
846+ if show_delta2 is True or show_mini_meta is True :
795847 ylim = contrast_axes .get_ylim ()
796848 redraw_axes_kwargs ['y' ] = ylim [0 ]
797849 x_ticks = contrast_axes .get_xticks ()
@@ -854,17 +906,17 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
854906
855907
856908 if show_delta2 is True :
857- if plot_kwargs ['delta_label ' ] is None :
858- delta_label = "delta - delta"
909+ if plot_kwargs ['delta2_label ' ] is None :
910+ delta2_label = "delta - delta"
859911 else :
860- delta_label = plot_kwargs ['delta_label ' ]
861- delta_axes = contrast_axes .twinx ()
862- delta_axes .set_frame_on (False )
863- delta_axes .set_ylabel (delta_label )
912+ delta2_label = plot_kwargs ['delta2_label ' ]
913+ delta2_axes = contrast_axes .twinx ()
914+ delta2_axes .set_frame_on (False )
915+ delta2_axes .set_ylabel (delta2_label )
864916 og_xlim_delta = contrast_axes .get_xlim ()
865917 og_ylim_delta = contrast_axes .get_ylim ()
866- delta_axes .set_ylim (og_ylim_delta )
867- delta_axes .vlines (og_xlim_delta [1 ],
918+ delta2_axes .set_ylim (og_ylim_delta )
919+ delta2_axes .vlines (og_xlim_delta [1 ],
868920 og_ylim_delta [0 ], og_ylim_delta [1 ],
869921 ** redraw_axes_kwargs )
870922
0 commit comments