diff --git a/droplet_growth/poisson.py b/droplet_growth/poisson.py index cd7916561ea4739b6cf5518f263987d5f586cc20..e046b956b9ca67a9e290c744ff938f6444ef9ff3 100644 --- a/droplet_growth/poisson.py +++ b/droplet_growth/poisson.py @@ -5,7 +5,7 @@ import numpy as np def fit(numbers:np.ndarray, max_value=None, xlabel='Initial number of cells', - title='', plot=True): + title='', plot=True, save_fig_path=None): if max_value is None: max_value = numbers.max() bins = np.arange(max_value + 1) - .5 @@ -19,5 +19,11 @@ def fit(numbers:np.ndarray, max_value=None, xlabel='Initial number of cells', plt.xlabel(xlabel) plt.title(title) plt.legend() + if save_fig_path is not None: + try: + plt.savefig(save_fig_path) + print(f'Save histogram {save_fig_path}') + except Exception as e: + print('saving histogram failed', e.args) plt.show() return l