From 6741d40e132c1626201914bd523fd00a09b913f6 Mon Sep 17 00:00:00 2001 From: frederik Date: Fri, 5 Apr 2024 14:53:58 +0200 Subject: [PATCH] add option to include all detections, and make default --- scripts/daily_plot.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index 5e3ac85..4bcfc16 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -33,12 +33,16 @@ def get_data(now=None): return df, now -def create_plot(df_plt_today, now, is_top): - readings = 10 - if is_top: - plt_selection_today = (df_plt_today['Com_Name'].value_counts()[:readings]) +def create_plot(df_plt_today, now, is_top=None): + if is_top is not None: + readings = 10 + if is_top: + plt_selection_today = (df_plt_today['Com_Name'].value_counts()[:readings]) + else: + plt_selection_today = (df_plt_today['Com_Name'].value_counts()[-readings:]) else: - plt_selection_today = (df_plt_today['Com_Name'].value_counts()[-readings:]) + plt_selection_today = df_plt_today['Com_Name'].value_counts() + readings = len(df_plt_today['Com_Name'].value_counts()) df_plt_selection_today = df_plt_today[df_plt_today.Com_Name.isin(plt_selection_today.index)] @@ -56,11 +60,14 @@ def create_plot(df_plt_today, now, is_top): # norm values for color palette norm = plt.Normalize(confmax.values.min(), confmax.values.max()) - if is_top: + if is_top or is_top is None: # Set Palette for graphics pal = "Greens" colors = plt.cm.Greens(norm(confmax)).tolist() - plot_type = "Top" + if is_top: + plot_type = "Top" + else: + plot_type = 'All' name = "Combo" else: # Set Palette for graphics @@ -141,8 +148,7 @@ def main(daemon, sleep_m): else: data, time = get_data(now) if not data.empty: - create_plot(data, time, is_top=True) - create_plot(data, time, is_top=False) + create_plot(data, time) else: print('empty dataset') if daemon: