Skip to content
This repository was archived by the owner on Aug 1, 2022. It is now read-only.
This repository was archived by the owner on Aug 1, 2022. It is now read-only.

Crash for barplots #48

@kpj

Description

@kpj

There is a crash when trying to plot annotations for a barplot in statannot-0.2.3 and seaborn-0.10.0.

Consider the following code:

import numpy as np
import pandas as pd

import statannot
import seaborn as sns

import matplotlib.pyplot as plt


np.random.seed(42)
df = pd.DataFrame({
    'y': np.random.random(size=50),
    'x': np.random.choice(['X1', 'X2'], size=50),
})

ax = sns.barplot(x='x', y='y', data=df)
statannot.add_stat_annotation(
    ax, plot='barplot',
    data=df, x='x', y='y',
    box_pairs=[('X1', 'X2')],
    test='Mann-Whitney', text_format='simple'
)

plt.show()

It crashes with the error

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    test='Mann-Whitney', text_format='simple'
  File "../python/site-packages/statannot/statannot.py", line 442, in add_stat_annotation
    errcolor=".26", errwidth=None, capsize=None, dodge=True)
TypeError: __init__() missing 1 required positional argument: 'seed'

This bug can be fixed by adding e.g. seed=None, in

box_plotter = sns.categorical._BarPlotter(
x, y, hue, data, order, hue_order,
estimator=np.mean, ci=95, n_boot=1000, units=None,
orient=None, color=None, palette=None, saturation=.75,
errcolor=".26", errwidth=None, capsize=None, dodge=True)
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions