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

Fix bug observed while plotting dot plots with small number of samples #20

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions uadapy/plotting/plots1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def calculate_offsets(count, max_count):

def calculate_dot_size(num_samples, scale_factor):
if num_samples < 100:
dot_size = 3.125
dot_size = scale_factor * 3.125
else:
dot_size = scale_factor * (50 /(4 ** np.log10(num_samples)))
return dot_size
Expand Down Expand Up @@ -202,7 +202,10 @@ def plot_1d_distribution(distributions, num_samples, plot_types:list, seed=55, f
dot_size = kwargs['dot_size']
if 'stripplot' in plot_types:
if 'dot_size' not in kwargs:
scale_factor = 1 + np.log10(num_samples/100)
if num_samples < 100:
scale_factor = 1
else:
scale_factor = 1 + np.log10(num_samples/100)
dot_size = calculate_dot_size(len(sample[:,index]), scale_factor)
if kwargs.get('vert',True):
sns.stripplot(x=[k]*len(sample[:,index]), y=sample[:,index], color=palette[k % len(palette)], size=dot_size, jitter=0.25, ax=ax)
Expand Down