highlight current hour label on daily_plot
This commit is contained in:
+16
-6
@@ -81,24 +81,25 @@ plot.set(xlabel="Detections")
|
|||||||
|
|
||||||
|
|
||||||
# Generate crosstab matrix for heatmap plot
|
# Generate crosstab matrix for heatmap plot
|
||||||
|
|
||||||
heat = pd.crosstab(df_plt_top10_today['Com_Name'], df_plt_top10_today['Hour of Day'])
|
heat = pd.crosstab(df_plt_top10_today['Com_Name'], df_plt_top10_today['Hour of Day'])
|
||||||
|
|
||||||
# Order heatmap Birds by frequency of occurrance
|
# Order heatmap Birds by frequency of occurrance
|
||||||
heat.index = pd.CategoricalIndex(heat.index, categories=freq_order)
|
heat.index = pd.CategoricalIndex(heat.index, categories=freq_order)
|
||||||
heat.sort_index(level=0, inplace=True)
|
heat.sort_index(level=0, inplace=True)
|
||||||
|
|
||||||
|
|
||||||
hours_in_day = pd.Series(data=range(0, 24))
|
hours_in_day = pd.Series(data=range(0, 24))
|
||||||
heat_frame = pd.DataFrame(data=0, index=heat.index, columns=hours_in_day)
|
heat_frame = pd.DataFrame(data=0, index=heat.index, columns=hours_in_day)
|
||||||
heat = (heat + heat_frame).fillna(0)
|
heat = (heat + heat_frame).fillna(0)
|
||||||
|
|
||||||
# Generatie heatmap plot
|
# Get current hour
|
||||||
|
current_hour = now.hour
|
||||||
|
|
||||||
|
# Generate heatmap plot
|
||||||
plot = sns.heatmap(
|
plot = sns.heatmap(
|
||||||
heat,
|
heat,
|
||||||
norm=LogNorm(),
|
norm=LogNorm(),
|
||||||
annot=True,
|
annot=True,
|
||||||
annot_kws={
|
annot_kws={"fontsize": 7},
|
||||||
"fontsize": 7},
|
|
||||||
fmt="g",
|
fmt="g",
|
||||||
cmap=pal,
|
cmap=pal,
|
||||||
square=False,
|
square=False,
|
||||||
@@ -106,9 +107,18 @@ plot = sns.heatmap(
|
|||||||
linewidths=0.5,
|
linewidths=0.5,
|
||||||
linecolor="Grey",
|
linecolor="Grey",
|
||||||
ax=axs[1],
|
ax=axs[1],
|
||||||
yticklabels=False)
|
yticklabels=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set color and weight of tick label for current hour
|
||||||
|
for label in plot.get_xticklabels():
|
||||||
|
if int(label.get_text()) == current_hour:
|
||||||
|
label.set_color('yellow')
|
||||||
|
|
||||||
plot.set_xticklabels(plot.get_xticklabels(), rotation=0, size=7)
|
plot.set_xticklabels(plot.get_xticklabels(), rotation=0, size=7)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set heatmap border
|
# Set heatmap border
|
||||||
for _, spine in plot.spines.items():
|
for _, spine in plot.spines.items():
|
||||||
spine.set_visible(True)
|
spine.set_visible(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user