Skip to content

Commit

Permalink
Hide mean in violin plot
Browse files Browse the repository at this point in the history
Change showmeans in violin plot from being always True to a kwarg key
  • Loading branch information
Tamir-K authored and hageldave committed Jul 31, 2024
1 parent 406d138 commit 2b73fc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions uadapy/plotting/plots1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down Expand Up @@ -184,15 +187,16 @@ 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)])
pc.set_alpha(0.5)
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']
Expand Down

0 comments on commit 2b73fc0

Please sign in to comment.