Skip to content

Commit f4e1d63

Browse files
committed
Update summary_bars name to reference_band
Update summary bar name to reference band
1 parent 3890c06 commit f4e1d63

16 files changed

+212
-208
lines changed

README.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,52 +40,56 @@ performance improvements. It’s a big one!
4040

4141
5. **Other Visualization Improvements**:
4242

43-
- **Raw, Contrast, and Summary bars**: Our visualization package now
44-
includes three types of customizable bars to enhance data
45-
interpretation:
46-
47-
- **Raw Bars**: Colored rectangles that extend from the zero line
48-
to the mean of each group’s raw data. These bars visually
49-
highlight the central tendency of the raw data.
50-
51-
- **Contrast Bars**: Similar to raw bars, these highlight the
52-
effect size difference between two groups (typically test and
53-
control) in the contrast axis. They provide a visual
54-
representation of the differences between groups.
55-
56-
- **Summary Bars**: Optional bars that can be added to emphasize a
57-
specific effect size across the entire contrast axis. Unlike raw
58-
and contrast bars, these span horizontally (or vertically if
59-
`horizontal=True`) and are not displayed by default.
43+
- **Comparing means and effect sizes**: The estimation plots now
44+
include three types of customizable visual features to enhance
45+
contextualization and comparison of means and effect sizes:
46+
47+
- **Bars for the mean of the observed values (`raw_bars`)**:
48+
Colored rectangles that extend from the zero line to the mean of
49+
each group’s raw data. These bars visually highlight the central
50+
tendency of the raw data.
51+
52+
- **Bars for effect size/s (`contrast_bars`)**: Similar to raw
53+
bars, these highlight the effect-size difference between two
54+
groups (typically test and control) in the contrast axis. They
55+
provide a visual representation of the differences between
56+
groups.
57+
58+
- **Summary bands (`reference_band`)**: An optional band or ribbon
59+
that can be added to emphasize a specific effect size’s
60+
confidence interval that is used as a reference range across the
61+
entire contrast axis. Unlike raw and contrast bars, these span
62+
horizontally (or vertically if `horizontal=True`) and are not
63+
displayed by default.
6064

6165
Raw and contrast bars are shown by default. Users can customize
62-
these bars and add summary bars as needed. For detailed
66+
these bars and add summary bands as needed. For detailed
6367
customization instructions, please refer to the [Plot Aesthetics
6468
tutorial](../tutorials/09-plot_aesthetics.html).
6569

66-
- **Tighter spacing in Delta-Delta and Mini-Meta Plots**: We have
70+
- **Tighter spacing in delta-delta and mini-meta plots**: We have
6771
adjusted the spacing of delta-delta and mini-meta plots to reduce
6872
whitespace. The new format brings the overall effect size closer
6973
to the two-groups effect sizes. In addition, delta-delta plots now
7074
have a gap in the zero line to separate the delta-delta from the ∆
7175
effect sizes.
7276

73-
- **Delta-Delta Effect Sizes for Proportion Plots**: In addition to
77+
- **Delta-delta effect sizes for proportion plots**: In addition to
7478
continuous data, delta-delta plots now support binary data
7579
(proportions). This means that 2-way designs for binary outcomes
7680
can be analyzed with DABEST.
7781

78-
- **Proportion Plots Sample Sizes**: The sample size of each binary
82+
- **Proportion plots sample sizes**: The sample size of each binary
7983
option for each group can now be displayed. These can be toggled
8084
on/off via the `prop_sample_counts` parameter.
8185

82-
- **Effect Size Lines for Paired Plots**: Along with lines
86+
- **Effect size lines for paired plots**: Along with lines
8387
connecting paired observed values, the paired plots now also
8488
display lines linking the effect sizes within a group in the
8589
contrast axes. These lines can be toggled on/off via the
8690
`contrast_paired_lines` parameter.
8791

88-
- **Baseline Error Curves**: To represent the baseline/control group
92+
- **Baseline error curves**: To represent the baseline/control group
8993
in the contrast axes, it is now possible to plot the baseline dot
9094
and the baseline error curve. The dot is shown by default, while
9195
the curve can be toggled on/off via the `show_baseline_ec`
@@ -94,25 +98,25 @@ performance improvements. It’s a big one!
9498
be used to show that the baseline itself is an estimate inferred
9599
from the observed values of the control data.
96100

97-
- **Delta Text**: Effect-size deltas (e.g. mean differences) are now
101+
- **Delta text**: Effect-size deltas (e.g. mean differences) are now
98102
displayed as numerals next to their respective effect size. This
99103
can be toggled on/off via the `delta_text` parameter.
100104

101-
- **Empty Circle Color Palette**: A new swarmplot color palette
105+
- **Empty circle color palette**: A new swarmplot color palette
102106
modification is available for unpaired plots via the
103107
`empty_circle` parameter in the `.plot()` method. This option
104108
modifies the two-group swarmplots to have empty circles for the
105109
control group and filled circles for the experimental group.
106110

107111
6. **Miscellaneous Improvements & Adjustments**
108112

109-
- **Numba for Speed Improvements**: We have added
113+
- **Numba for speed improvements**: We have added
110114
[Numba](https://numba.pydata.org/) to speed up the various
111115
calculations in DABEST. Precalculations will be performed during
112116
import, which will help speed up the subsequent loading and
113117
plotting of data.
114118

115-
- **Terminology/Naming Updates**: During the refactoring of the
119+
- **Terminology/naming updates**: During the refactoring of the
116120
code, we have made several updates to the documentation and
117121
terminology to improve clarity and consistency. For example:
118122

@@ -131,11 +135,11 @@ performance improvements. It’s a big one!
131135
alongside these (if a delta-delta experiment was loaded
132136
correctly).
133137

134-
- **Updated Tutorial Pages**: We have updated the tutorial pages to
138+
- **Updated tutorial pages**: We have updated the tutorial pages to
135139
reflect the new features and changes. The tutorial pages are now
136140
more comprehensive and (hopefully!) more intuitive!
137141

138-
- **Results Dataframe for Delta-Delta and Mini-Meta Plots**: A
142+
- **Results dataframe for delta-delta and mini-meta plots**: A
139143
results dataframe can now be extracted for both the delta-delta
140144
and mini-meta effect size data (similar to the results dataframe
141145
for the regular effect sizes). These can be found via the

dabest/_effsize_objects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,8 @@ def plot(
11861186
raw_bars_kwargs=None, # swarm_bars_kwargs=None, OLD
11871187
contrast_bars=True,
11881188
contrast_bars_kwargs=None,
1189-
summary_bars=None,
1190-
summary_bars_kwargs=None,
1189+
reference_band=None,
1190+
reference_band_kwargs=None,
11911191
delta_text=True,
11921192
delta_text_kwargs=None,
11931193
delta_dot=True,
@@ -1386,10 +1386,10 @@ def plot(
13861386
Pass relevant keyword arguments to the contrast bars. Pass any keyword arguments accepted by
13871387
matplotlib.patches.Rectangle here, as a string. If None, the following keywords are passed:
13881388
{"color": None, "zorder":-3}
1389-
summary_bars : list, default None
1390-
Pass a list of indices of the contrast objects to have summary bars displayed on the plot.
1391-
For example, [0,1] will show summary bars for the first two contrast objects.
1392-
summary_bars_kwargs: dict, default None
1389+
reference_band : list, default None
1390+
Pass a list of indices of the contrast objects to have reference bands displayed on the plot.
1391+
For example, [0,1] will show reference bands for the first two contrast objects.
1392+
reference_band_kwargs: dict, default None
13931393
If None, the following keywords are passed: {"span_ax": False, "color": None, "alpha": 0.15, "zorder":-3}
13941394
delta_text : boolean, default True
13951395
Whether or not to display the text deltas.

dabest/forest_plot.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ def check_for_errors(**kwargs):
264264
if not isinstance(remove_spines, bool):
265265
raise TypeError("`remove_spines` must be a boolean value.")
266266

267-
# Summary bars
268-
summary_bars = kwargs.get('summary_bars')
269-
if summary_bars is not None:
270-
if not isinstance(summary_bars, list | tuple):
271-
raise TypeError("`summary_bars` must be a list/tuple of indices (ints).")
272-
if not all(isinstance(i, int) for i in summary_bars):
273-
raise TypeError("`summary_bars` must be a list/tuple of indices (ints).")
274-
if any(i >= number_of_curves_to_plot for i in summary_bars):
275-
raise ValueError("Index {} chosen is out of range for the contrast objects.".format([i for i in summary_bars if i >= number_of_curves_to_plot]))
267+
# Reference band
268+
reference_band = kwargs.get('reference_band')
269+
if reference_band is not None:
270+
if not isinstance(reference_band, list | tuple):
271+
raise TypeError("`reference_band` must be a list/tuple of indices (ints).")
272+
if not all(isinstance(i, int) for i in reference_band):
273+
raise TypeError("`reference_band` must be a list/tuple of indices (ints).")
274+
if any(i >= number_of_curves_to_plot for i in reference_band):
275+
raise ValueError("Index {} chosen is out of range for the contrast objects.".format([i for i in reference_band if i >= number_of_curves_to_plot]))
276276

277277
# Delta text
278278
delta_text = kwargs.get('delta_text')
@@ -296,7 +296,7 @@ def get_kwargs(
296296
errorbar_kwargs,
297297
delta_text_kwargs,
298298
contrast_bars_kwargs,
299-
summary_bars_kwargs,
299+
reference_band_kwargs,
300300
marker_size
301301
):
302302
from .misc_tools import merge_two_dicts
@@ -377,20 +377,20 @@ def get_kwargs(
377377
else:
378378
contrast_bars_kwargs = merge_two_dicts(default_contrast_bars_kwargs, contrast_bars_kwargs)
379379

380-
# Summary bars kwargs.
381-
default_summary_bars_kwargs = {
380+
# reference band kwargs.
381+
default_reference_band_kwargs = {
382382
"span_ax": False,
383383
"color": None,
384384
"alpha": 0.15,
385385
"zorder":-3
386386
}
387-
if summary_bars_kwargs is None:
388-
summary_bars_kwargs = default_summary_bars_kwargs
387+
if reference_band_kwargs is None:
388+
reference_band_kwargs = default_reference_band_kwargs
389389
else:
390-
summary_bars_kwargs = merge_two_dicts(default_summary_bars_kwargs, summary_bars_kwargs)
390+
reference_band_kwargs = merge_two_dicts(default_reference_band_kwargs, reference_band_kwargs)
391391

392392
return (violin_kwargs, zeroline_kwargs, marker_kwargs, errorbar_kwargs,
393-
delta_text_kwargs, contrast_bars_kwargs, summary_bars_kwargs)
393+
delta_text_kwargs, contrast_bars_kwargs, reference_band_kwargs)
394394

395395
def color_palette(
396396
custom_palette,
@@ -448,8 +448,8 @@ def forest_plot(
448448

449449
contrast_bars: bool = True,
450450
contrast_bars_kwargs: dict = None,
451-
summary_bars: list|tuple = None,
452-
summary_bars_kwargs: dict = None,
451+
reference_band: list|tuple = None,
452+
reference_band_kwargs: dict = None,
453453

454454
violin_kwargs: Optional[dict] = None,
455455
zeroline_kwargs: Optional[dict] = None,
@@ -516,10 +516,10 @@ def forest_plot(
516516
If True, it adds bars from the zeroline to the effect size curve.
517517
contrast_bars_kwargs : dict, default=None
518518
Additional keyword arguments for the contrast_bars.
519-
summary_bars: list | tuple, default=None,
520-
If True, it adds summary bars to the relevant effect size curves.
521-
summary_bars_kwargs : dict, default=None,
522-
Additional keyword arguments for the summary_bars.
519+
reference_band: list | tuple, default=None,
520+
It adds reference bands to the relevant effect size curves.
521+
reference_band_kwargs : dict, default=None,
522+
Additional keyword arguments for the reference_band.
523523
violin_kwargs : Optional[dict], default=None
524524
Additional arguments for violin plot customization.
525525
zeroline_kwargs : Optional[dict], default=None
@@ -559,15 +559,15 @@ def forest_plot(
559559

560560
# Get Kwargs
561561
(violin_kwargs, zeroline_kwargs, marker_kwargs, errorbar_kwargs,
562-
delta_text_kwargs, contrast_bars_kwargs, summary_bars_kwargs) = get_kwargs(
562+
delta_text_kwargs, contrast_bars_kwargs, reference_band_kwargs) = get_kwargs(
563563
violin_kwargs = violin_kwargs,
564564
zeroline_kwargs = zeroline_kwargs,
565565
horizontal = horizontal,
566566
marker_kwargs = marker_kwargs,
567567
errorbar_kwargs = errorbar_kwargs,
568568
delta_text_kwargs = delta_text_kwargs,
569569
contrast_bars_kwargs = contrast_bars_kwargs,
570-
summary_bars_kwargs = summary_bars_kwargs,
570+
reference_band_kwargs = reference_band_kwargs,
571571
marker_size = marker_size
572572
)
573573

@@ -726,19 +726,19 @@ def forest_plot(
726726
else:
727727
ax.add_patch(mpatches.Rectangle((x, 0), 0.25, y, color=bar_colors[x-1], **contrast_bars_kwargs))
728728

729-
# Summary bars
730-
if summary_bars:
731-
_bar_color = summary_bars_kwargs.pop('color')
729+
# Reference band
730+
if reference_band:
731+
_bar_color = reference_band_kwargs.pop('color')
732732
if _bar_color is not None:
733733
bar_colors = [_bar_color] * number_of_curves_to_plot
734734
else:
735735
bar_colors = violin_colors
736736

737-
span_ax = summary_bars_kwargs.pop("span_ax")
737+
span_ax = reference_band_kwargs.pop("span_ax")
738738
summary_xmin, summary_xmax = ax.get_xlim()
739739
summary_ymin, summary_ymax = ax.get_ylim()
740740

741-
for summary_index in summary_bars:
741+
for summary_index in reference_band:
742742
if span_ax == True:
743743
starting_location = summary_ymin if horizontal else summary_xmin
744744
else:
@@ -752,14 +752,14 @@ def forest_plot(
752752
(summary_ci_low, starting_location),
753753
summary_ci_high-summary_ci_low, summary_ymax+1,
754754
color=summary_color,
755-
**summary_bars_kwargs)
755+
**reference_band_kwargs)
756756
)
757757
else:
758758
ax.add_patch(mpatches.Rectangle(
759759
(starting_location, summary_ci_low),
760760
summary_xmax+1, summary_ci_high-summary_ci_low,
761761
color=summary_color,
762-
**summary_bars_kwargs)
762+
**reference_band_kwargs)
763763
)
764764

765765
## Invert Y-axis if horizontal

dabest/misc_tools.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,16 @@ def get_kwargs(
385385
else:
386386
delta_text_kwargs = merge_two_dicts(default_delta_text_kwargs, plot_kwargs["delta_text_kwargs"])
387387

388-
# Summary bars kwargs.
389-
default_summary_bars_kwargs = {
388+
# Reference band kwargs.
389+
default_reference_band_kwargs = {
390390
"span_ax": False,
391391
"alpha": 0.15,
392392
"zorder":-3
393393
}
394-
if plot_kwargs["summary_bars_kwargs"] is None:
395-
summary_bars_kwargs = default_summary_bars_kwargs
394+
if plot_kwargs["reference_band_kwargs"] is None:
395+
reference_band_kwargs = default_reference_band_kwargs
396396
else:
397-
summary_bars_kwargs = merge_two_dicts(default_summary_bars_kwargs, plot_kwargs["summary_bars_kwargs"])
397+
reference_band_kwargs = merge_two_dicts(default_reference_band_kwargs, plot_kwargs["reference_band_kwargs"])
398398

399399
# Swarm bars kwargs.
400400
default_raw_bars_kwargs = {
@@ -501,7 +501,7 @@ def get_kwargs(
501501
# Return the kwargs.
502502
return (swarmplot_kwargs, barplot_kwargs, sankey_kwargs, contrast_kwargs, slopegraph_kwargs,
503503
reflines_kwargs, legend_kwargs, group_summaries_kwargs, redraw_axes_kwargs, delta_dot_kwargs,
504-
delta_text_kwargs, summary_bars_kwargs, raw_bars_kwargs, contrast_bars_kwargs, table_kwargs, gridkey_kwargs,
504+
delta_text_kwargs, reference_band_kwargs, raw_bars_kwargs, contrast_bars_kwargs, table_kwargs, gridkey_kwargs,
505505
contrast_marker_kwargs, contrast_errorbar_kwargs, prop_sample_counts_kwargs, contrast_paired_lines_kwargs)
506506

507507

@@ -1880,7 +1880,7 @@ def color_picker(color_type: str,
18801880
def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, color_col, show_pairs,
18811881
plot_data = None, xvar = None, yvar = None, # Raw data
18821882
results = None, ticks_to_plot = None, extra_delta = None, # Contrast data
1883-
summary_bars = None, summary_axes = None, ci_type = None # Summary data
1883+
reference_band = None, summary_axes = None, ci_type = None # Summary data
18841884
):
18851885
from .misc_tools import color_picker
18861886
bar_dict = {}
@@ -1905,20 +1905,20 @@ def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, co
19051905

19061906
elif bar_type == 'summary':
19071907
# Begin checks
1908-
if not isinstance(summary_bars, list):
1909-
raise TypeError("summary_bars must be a list of indices (ints).")
1910-
if not all(isinstance(i, int) for i in summary_bars):
1911-
raise TypeError("summary_bars must be a list of indices (ints).")
1912-
if any(i >= len(results) for i in summary_bars):
1913-
raise ValueError("Index {} chosen is out of range for the contrast objects.".format([i for i in summary_bars if i >= len(results)]))
1914-
1915-
ticks = [ticks_to_plot[tick] for tick in summary_bars]
1908+
if not isinstance(reference_band, list):
1909+
raise TypeError("reference_band must be a list of indices (ints).")
1910+
if not all(isinstance(i, int) for i in reference_band):
1911+
raise TypeError("reference_band must be a list of indices (ints).")
1912+
if any(i >= len(results) for i in reference_band):
1913+
raise ValueError("Index {} chosen is out of range for the contrast objects.".format([i for i in reference_band if i >= len(results)]))
1914+
1915+
ticks = [ticks_to_plot[tick] for tick in reference_band]
19161916
summary_xmin, summary_xmax = summary_axes.get_xlim()
19171917
summary_ymin, summary_ymax = summary_axes.get_ylim()
19181918
span_ax = bar_kwargs.pop("span_ax")
19191919

19201920
x_start_values, y_start_values, x_distances, y_distances = [], [], [], []
1921-
for summary_index in summary_bars:
1921+
for summary_index in reference_band:
19221922
summary_ci_low = results.get(ci_type+'_low')[summary_index]
19231923
summary_ci_high = results.get(ci_type+'_high')[summary_index]
19241924

0 commit comments

Comments
 (0)