ACCLAB / DABEST-python

Data Analysis with Bootstrapped ESTimation
https://acclab.github.io/DABEST-python/
Apache License 2.0
337 stars 46 forks source link

Plot ONLY mean diff #107

Open ELind77 opened 3 years ago

ELind77 commented 3 years ago

Hi all,

I've really enjoyed using this library but as I scale up to larger data sets I've fount that plotting takes forever. I suspect that this is largely due to the swarm plots (though I could be wrong) and I often want to show only the mean difference plots when I summarize findings. Is there a way to plot only the mean diff plot or could such a method be added if it doesn't already exist?

-- Eric

ELind77 commented 3 years ago

This works pretty well in a notebook:

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from dabest import plot_tools

ax = plt.gca()

for row in db_full.mean_diff.results.itertuples():
    v = ax.violinplot(row.bootstraps[~np.isinf(row.bootstraps)], positions=[row.Index])
    plot_tools.halfviolin(v, fill_color=sns.color_palette()[row.Index])

    # Effect size
    ax.plot([row.Index], row.difference, marker="o", color=plt.rcParams["ytick.color"])
    # Confidence interval
    ax.plot([row.Index, row.Index], [row.bca_low, row.bca_high], linestyle="-", color=plt.rcParams["ytick.color"])

ax.set_xticks(db_full.mean_diff.results.index)
ax.set_xticklabels(db_full.mean_diff.results.test);

Would be nice to factor out this part of the plotter module so that this could be called separately.