-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark daily chart #152
Dark daily chart #152
Changes from 17 commits
596c22b
1d80966
be1054e
0e574b4
e18a260
f363bbd
66fc3b7
810e293
6b8ca14
2bf1c4c
bdfe356
b0c1aa1
df58b51
08a7568
254734f
1d09798
76bf800
1f3e00c
b59c646
a7a6a72
577215a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,8 @@ def get_data(now=None): | |
|
||
# Function to show value on bars - from https://stackoverflow.com/questions/43214978/seaborn-barplot-displaying-values | ||
def show_values_on_bars(ax, label): | ||
conf = get_settings() | ||
|
||
for i, p in enumerate(ax.patches): | ||
x = p.get_x() + p.get_width() * 0.9 | ||
y = p.get_y() + p.get_height() / 2 | ||
|
@@ -43,7 +45,11 @@ def show_values_on_bars(ax, label): | |
# Species Count Total | ||
value = '{:n}'.format(p.get_width()) | ||
bbox = {'facecolor': 'lightgrey', 'edgecolor': 'none', 'pad': 1.0} | ||
ax.text(x, y, value, bbox=bbox, ha='center', va='center', size=9, color='darkgreen') | ||
match conf['COLOR_SCHEME']: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Match was only introduced with Python 3.10; this was giving the syntax error earlier. Could you change to a if/else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, which is why I moved the version to 3.11. If we're not updating the Python version I can change this to an if/else - it's just a less elegant solution. |
||
case "dark": | ||
ax.text(x, y, value, bbox=bbox, ha='center', va='center', size=9, color='black') | ||
case _: | ||
ax.text(x, y, value, bbox=bbox, ha='center', va='center', size=9, color='darkgreen') | ||
|
||
|
||
def wrap_width(txt): | ||
|
@@ -70,9 +76,15 @@ def create_plot(df_plt_today, now, is_top=None): | |
|
||
df_plt_selection_today = df_plt_today[df_plt_today.Com_Name.isin(plt_selection_today.index)] | ||
|
||
conf = get_settings() | ||
|
||
# Set up plot axes and titles | ||
height = max(readings / 3, 0) + 1.06 | ||
f, axs = plt.subplots(1, 2, figsize=(10, height), gridspec_kw=dict(width_ratios=[3, 6]), facecolor='#77C487') | ||
match conf['COLOR_SCHEME']: | ||
case "dark": | ||
f, axs = plt.subplots(1, 2, figsize=(10, height), gridspec_kw=dict(width_ratios=[3, 6]), facecolor='darkgrey') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
case _: | ||
f, axs = plt.subplots(1, 2, figsize=(10, height), gridspec_kw=dict(width_ratios=[3, 6]), facecolor='none') | ||
|
||
# generate y-axis order for all figures based on frequency | ||
freq_order = df_plt_selection_today['Com_Name'].value_counts().index | ||
|
@@ -86,8 +98,13 @@ def create_plot(df_plt_today, now, is_top=None): | |
norm = plt.Normalize(confmax.values.min(), confmax.values.max()) | ||
if is_top or is_top is None: | ||
# Set Palette for graphics | ||
pal = "Greens" | ||
colors = plt.cm.Greens(norm(confmax)).tolist() | ||
match conf['COLOR_SCHEME']: | ||
case "dark": | ||
pal = "Greys" | ||
colors = plt.cm.Greys(norm(confmax)).tolist() | ||
case _: | ||
pal = "Greens" | ||
colors = plt.cm.Greens(norm(confmax)).tolist() | ||
if is_top: | ||
plot_type = "Top" | ||
else: | ||
|
@@ -102,7 +119,7 @@ def create_plot(df_plt_today, now, is_top=None): | |
|
||
# Generate frequency plot | ||
plot = sns.countplot(y='Com_Name', hue='Com_Name', legend=False, data=df_plt_selection_today, | ||
palette=colors, order=freq_order, ax=axs[0]) | ||
palette=colors, order=freq_order, ax=axs[0], edgecolor='lightgrey') | ||
Nachtzuster marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Prints Max Confidence on bars | ||
show_values_on_bars(axs[0], confmax) | ||
|
@@ -136,7 +153,11 @@ def create_plot(df_plt_today, now, is_top=None): | |
# Set color and weight of tick label for current hour | ||
for label in plot.get_xticklabels(): | ||
if int(label.get_text()) == now.hour: | ||
label.set_color('yellow') | ||
match conf['COLOR_SCHEME']: | ||
case "dark": | ||
label.set_color('white') | ||
case _: | ||
label.set_color('yellow') | ||
|
||
plot.set_xticklabels(plot.get_xticklabels(), rotation=0, size=8) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,7 @@ fi | |
if [ -L /usr/local/bin/analyze.py ];then | ||
rm -f /usr/local/bin/analyze.py | ||
fi | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't do changes in unrelated files There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if [ -L /usr/local/bin/birdnet_analysis.sh ];then | ||
rm -f /usr/local/bin/birdnet_analysis.sh | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stay on 3.9: people that migrated their installation in place from the original BirdNET-Pi are still on 3.9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.9 is about 4 years old. When can we move to a more up to date version? Should updating Python and/or other dependencies be part of the update script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What Nachtzuster means (I think) is that birdnet pi has an incremental auto update feature. So if we change the dependency to a newer version of python incremental update won't work and it will break functionality for older users - to avoid needing to change the update logic he therefore prefers to avoid breaking changes such as this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think at some point we're going to want to have an update, if not for better Python features than to avoid any potential security issues. It doesn't need to be bleeding edge but generally speaking staying back leveled isn't ideal.
Edit: while my points are still valid I'll back level my code for the sake of back leveling my code.