Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: vertical error bars in tukeyhsd plot_simultaneous #9102

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

iboraham
Copy link


code
import matplotlib.pyplot as plt
from statsmodels.stats.multicomp import MultiComparison, pairwise_tukeyhsd

response = [4, 5, 7, 6, 2, 3, 12, 9, 7, 7]
groups = [
    "test1",
    "test1",
    "test2",
    "test2",
    "test3",
    "test3",
    "test4",
    "test4",
    "test5",
    "test5",
]

result = pairwise_tukeyhsd(response, groups, alpha=0.05)

# Plot the results
fig, ax = plt.subplots(figsize=(1, 1))

# Customize the plot appearance
result.plot_simultaneous(
    comparison_name="test3",
    ax=ax,
    figsize=(8, 5),
    xlabel="Response",  # X-axis label
    ylabel="Test Group",  # Y-axis label
    vertical=True,
)

# Reverse the order of labels on the y-axis
# ax.invert_yaxis() # off comments when vertical true

# Add a title to the plot
ax.set_title(f"Tukey's HSD Test for Response")

# Show the plot
plt.show()

Before:
before
After (with vertical=True):
after

@pep8speaks
Copy link

pep8speaks commented Dec 20, 2023

Hello @iboraham! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2023-12-20 10:52:30 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: option to flip plot axes, vertical error bars in tukeyhsd plot_simultaneous
2 participants