diff --git a/src/wela/plotting.py b/src/wela/plotting.py index 8e7c2d182474144f84d9e37e2f21efffc1a1760c..961ad11f913063d0ff9eadcbc3a2b6540d8c9101 100644 --- a/src/wela/plotting.py +++ b/src/wela/plotting.py @@ -538,6 +538,7 @@ def bud_to_bud_plot( df=None, title=None, filter_func=None, + show_figure=True, ): """ Plot the median and percentiles of a signal between consecutive buddings. @@ -571,6 +572,10 @@ def bud_to_bud_plot( Title for plot. filter_func: fn Filter to apply to each time series. + show_figure: boolean + If False, only plot is called and no figure created so multiple + data sets can be shown on the same plot by calling bud_to_bud_plot + multiple times. Example ------- @@ -624,7 +629,8 @@ def bud_to_bud_plot( right=np.nan, ) # plot median and percentiles - plt.figure() + if show_figure: + plt.figure() plt.plot(ntbins, np.nanmedian(new_signal, axis=0), f"{colour}.-") for lower, upper in zip([45, 40, 35], [55, 60, 65]): plt.fill_between( @@ -636,11 +642,12 @@ def bud_to_bud_plot( ) plt.xlabel("position between budding events") plt.ylabel(signal.replace("_", " ")) - plt.grid() - if title is None: - plt.title(f"{dl.dataname}: t={tpt}") - else: - plt.title(title) - plt.show(block=False) + if show_figure: + plt.grid() + if title is None: + plt.title(f"{dl.dataname}: t={tpt}") + else: + plt.title(title) + plt.show(block=False) if return_signal: return new_signal