From 23a35a289c021874e16bb90e66787bfa7091ee78 Mon Sep 17 00:00:00 2001 From: frederik Date: Fri, 5 Apr 2024 17:30:41 +0200 Subject: [PATCH] fix daily_plot could show zeros when max count/h is only one --- scripts/daily_plot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index e5cceb2..5e3ac85 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -7,6 +7,7 @@ from time import sleep import matplotlib.font_manager as font_manager import matplotlib.pyplot as plt +import numpy as np import pandas as pd import seaborn as sns from matplotlib import rcParams @@ -88,6 +89,8 @@ def create_plot(df_plt_today, now, is_top): hours_in_day = pd.Series(data=range(0, 24)) heat_frame = pd.DataFrame(data=0, index=heat.index, columns=hours_in_day) heat = (heat+heat_frame).fillna(0) + # mask out zeros, so they do not show up in the final plot. this happens when max count/h is one + heat[heat == 0] = np.nan # Generatie heatmap plot plot = sns.heatmap(heat, norm=LogNorm(), annot=True, annot_kws={"fontsize": 7}, fmt="g", cmap=pal, square=False,