From b99367d29853ad3f1d6fdabbe89b1271c2c8dbb9 Mon Sep 17 00:00:00 2001 From: frederik Date: Wed, 14 Feb 2024 19:00:41 +0100 Subject: [PATCH] fix deprecation warnings --- scripts/daily_plot.py | 9 +++++---- scripts/plotly_streamlit.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index bbf46b3..e5cceb2 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -46,7 +46,7 @@ def create_plot(df_plt_today, now, is_top): 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 - freq_order = pd.value_counts(df_plt_selection_today['Com_Name']).index + freq_order = df_plt_selection_today['Com_Name'].value_counts().index # make color for max confidence --> this groups by name and calculates max conf confmax = df_plt_selection_today.groupby('Com_Name')['Confidence'].max() @@ -58,18 +58,19 @@ def create_plot(df_plt_today, now, is_top): if is_top: # Set Palette for graphics pal = "Greens" - colors = plt.cm.Greens(norm(confmax)) + colors = plt.cm.Greens(norm(confmax)).tolist() plot_type = "Top" name = "Combo" else: # Set Palette for graphics pal = "Reds" - colors = plt.cm.Reds(norm(confmax)) + colors = plt.cm.Reds(norm(confmax)).tolist() plot_type = "Bottom" name = "Combo2" # Generate frequency plot - plot = sns.countplot(y='Com_Name', data=df_plt_selection_today, palette=colors, order=freq_order, ax=axs[0]) + plot = sns.countplot(y='Com_Name', hue='Com_Name', legend=False, data=df_plt_selection_today, + palette=colors, order=freq_order, ax=axs[0]) # Try plot grid lines between bars - problem at the moment plots grid lines on bars - want between bars yticklabels = ['\n'.join(textwrap.wrap(ticklabel.get_text(), 15)) for ticklabel in plot.get_yticklabels()] diff --git a/scripts/plotly_streamlit.py b/scripts/plotly_streamlit.py index 0832e4a..e376ded 100755 --- a/scripts/plotly_streamlit.py +++ b/scripts/plotly_streamlit.py @@ -256,7 +256,7 @@ if daily is False: # filt = df2['Com_Name'] == specie if specie == 'All': - df_counts = int(hourly[hourly.index == specie]['All']) + df_counts = int(hourly[hourly.index == specie]['All'].iloc[0]) fig = make_subplots( rows=3, cols=2, specs=[[{"type": "xy", "rowspan": 3}, {"type": "polar", "rowspan": 2}], @@ -371,7 +371,7 @@ if daily is False: daily = pd.crosstab(df5, df5.index.date, dropna=True, margins=True) fig.add_trace(go.Bar(x=daily.columns[:-1], y=daily.loc[specie][:-1], marker_color='seagreen'), row=3, col=1) st.plotly_chart(fig, use_container_width=True) # , config=config) - df_counts = int(hourly[hourly.index == specie]['All']) + df_counts = int(hourly[hourly.index == specie]['All'].iloc[0]) st.subheader('Total Detect:' + str('{:,}'.format(df_counts)) + ' Confidence Max:' + str('{:.2f}%'.format(max(df2[df2['Com_Name'] == specie]['Confidence']) * 100))