From 2b73fc0cb0f06fc7749a0be46dbac3a7f9336d12 Mon Sep 17 00:00:00 2001 From: "Tamir K." <121674805+Tamir-K@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:12:58 +0300 Subject: [PATCH] Hide mean in violin plot Change showmeans in violin plot from being always True to a kwarg key --- uadapy/plotting/plots1D.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uadapy/plotting/plots1D.py b/uadapy/plotting/plots1D.py index 9d41b95..f1c4ad1 100644 --- a/uadapy/plotting/plots1D.py +++ b/uadapy/plotting/plots1D.py @@ -145,6 +145,9 @@ def plot_1d_distribution(distributions, num_samples, plot_types:list, seed=55, f - dot_size : float, optional This parameter determines the size of the dots used in the 'stripplot' and 'swarmplot'. If not provided, the size is calculated based on the number of samples and the type of plot. + - showmeans : bool, optional + If True, display means in plot. Only effective on violin plot =. + Default is False. Returns ------- @@ -184,7 +187,7 @@ def plot_1d_distribution(distributions, num_samples, plot_types:list, seed=55, f showmeans=True, meanline=True, meanprops=dict(color="black", linestyle='-'), medianprops=dict(linewidth=0), vert=kwargs.get('vert', True)) if 'violinplot' in plot_types: - parts = ax.violinplot(sample[:,index], positions=[k], showmeans=True, vert=kwargs.get('vert', True)) + parts = ax.violinplot(sample[:,index], positions=[k], showmeans=kwargs.get('showmeans', False), vert=kwargs.get('vert', True)) for pc in parts['bodies']: pc.set_facecolor(palette[k % len(palette)]) pc.set_edgecolor(palette[k % len(palette)]) @@ -192,7 +195,8 @@ def plot_1d_distribution(distributions, num_samples, plot_types:list, seed=55, f parts['cbars'].remove() parts['cmaxes'].remove() parts['cmins'].remove() - parts['cmeans'].set_edgecolor('black') + if kwargs.get('showmeans', False): + parts['cmeans'].set_edgecolor('black') if 'stripplot' in plot_types or 'swarmplot' in plot_types or 'dotplot' in plot_types: if 'dot_size' in kwargs: dot_size = kwargs['dot_size']