TukeyHSDResults.plot_simultaneous(comparison_name=None, ax=None, figsize=(10, 6), xlabel=None, ylabel=None)[source]

Plot a universal confidence interval of each group mean

Visualize significant differences in a plot with one confidence interval per group instead of all pairwise confidence intervals.

comparison_namestr, optional

if provided, plot_intervals will color code all groups that are significantly different from the comparison_name red, and will color code insignificant groups gray. Otherwise, all intervals will just be plotted in black.

axmatplotlib axis, optional

An axis handle on which to attach the plot.

figsizetuple, optional

tuple for the size of the figure generated

xlabelstr, optional

Name to be displayed on x axis

ylabelstr, optional

Name to be displayed on y axis


handle to figure object containing interval plots


Multiple comparison tests are nice, but lack a good way to be visualized. If you have, say, 6 groups, showing a graph of the means between each group will require 15 confidence intervals. Instead, we can visualize inter-group differences with a single interval for each group mean. Hochberg et al. [1] first proposed this idea and used Tukey’s Q critical value to compute the interval widths. Unlike plotting the differences in the means and their respective confidence intervals, any two pairs can be compared for significance by looking for overlap.



>>> from statsmodels.examples.try_tukey_hsd import cylinders, cyl_labels
>>> from statsmodels.stats.multicomp import MultiComparison
>>> cardata = MultiComparison(cylinders, cyl_labels)
>>> results = cardata.tukeyhsd()
>>> results.plot_simultaneous()
<matplotlib.figure.Figure at 0x...>

This example shows an example plot comparing significant differences in group means. Significant differences at the alpha=0.05 level can be identified by intervals that do not overlap (i.e. USA vs Japan, USA vs Germany).

>>> results.plot_simultaneous(comparison_name="USA")
<matplotlib.figure.Figure at 0x...>

Optionally provide one of the group names to color code the plot to highlight group means different from comparison_name.

Last update: Dec 14, 2023