Skip to content

Commit ab9f744

Browse files
committed
Refactor make_alert_plot function to improve plot aesthetics and readability
1 parent d28fc6f commit ab9f744

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

anomstack/plots/plot.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ def make_alert_plot(
4545
n = len(df_plot)
4646

4747
ax1 = df_plot["metric_value"].plot(
48-
title=f"{metric_name} (n={n})", ax=axes[0], style="-o", color="royalblue"
48+
title=f"{metric_name} (n={n})",
49+
ax=axes[0],
50+
style="-",
51+
color="royalblue",
52+
markersize=3,
4953
)
5054
if "metric_value_smooth" in df_plot.columns:
5155
df_plot["metric_value_smooth"].plot(
52-
ax=axes[0], style="--", color="darkorange", label="Value Smooth"
56+
ax=axes[0],
57+
style="--",
58+
color="darkorange",
59+
label="metric_value_smooth"
5360
)
5461
ax1.axes.get_xaxis().set_visible(False)
5562
ax1.grid(True, which="both", linestyle="--", linewidth=0.5)
@@ -67,9 +74,10 @@ def make_alert_plot(
6774
alert_points = df_plot[df_plot["metric_alert"] == 1]
6875
ax2.scatter(
6976
alert_points.index,
70-
alert_points["metric_alert"],
77+
alert_points["metric_score"],
7178
color="red",
72-
label=alert_type
79+
label=alert_type,
80+
s=5,
7381
)
7482
ax2.axhline(
7583
threshold, color="lightgrey", linestyle="-.",
@@ -90,8 +98,8 @@ def make_alert_plot(
9098
ax2.locator_params(axis="x", nbins=25)
9199

92100
for idx in alert_points.index:
93-
ax1.axvline(idx, color="yellow", alpha=0.3)
94-
ax2.axvline(idx, color="yellow", alpha=0.3)
101+
ax1.axvline(idx, color="grey", alpha=0.2)
102+
ax2.axvline(idx, color="grey", alpha=0.2)
95103

96104
plt.tight_layout()
97105

0 commit comments

Comments
 (0)