--- daily_plot.py_orig 2024-01-06 11:54:05.187427468 -0500 +++ daily_plot.py 2024-01-07 17:01:40.190558288 -0500 @@ -17,6 +17,10 @@ table_rows = cursor.fetchall() +cursor.execute('SELECT DISTINCT (Com_Name) FROM detections WHERE Date = DATE('now', 'localtime')') + +uTable_rows = cursor.fetchall() + # df=pd.DataFrame(table_rows) # Convert Date and Time Fields to Panda's format @@ -43,7 +47,13 @@ df_plt_today = df_plt[df_plt['Date'] == now.strftime("%Y-%m-%d")] # Set number of species to report -readings = 10 +readings = 50 +if uTable_rows < readings: + gy=readings +else: + gy=uTable_rows + +gy = 0.4 * gy plt_top10_today = (df_plt_today['Com_Name'].value_counts()[:readings]) df_plt_top10_today = df_plt_today[df_plt_today.Com_Name.isin(plt_top10_today.index)] @@ -55,7 +65,7 @@ pal = "Greens" # Set up plot axes and titles -f, axs = plt.subplots(1, 2, figsize=(10, 4), gridspec_kw=dict(width_ratios=[3, 6]), facecolor='#77C487') +f, axs = plt.subplots(1, 2, figsize=(10, gy), gridspec_kw=dict(width_ratios=[3, 6]), facecolor='#77C487') plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0, hspace=0) # generate y-axis order for all figures based on frequency @@ -208,7 +218,7 @@ plot.set(xlabel="Hour of Day") # Set combined plot layout and titles f.subplots_adjust(top=0.9) -plt.suptitle("Bottom 10 Last Updated: " + str(now.strftime("%Y-%m-%d %H:%M"))) +plt.suptitle("Bottom 50 Last Updated: " + str(now.strftime("%Y-%m-%d %H:%M"))) # Save combined plot savename = userDir + '/BirdSongs/Extracted/Charts/Combo2-' + str(now.strftime("%Y-%m-%d")) + '.png'