File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 2424from anomstack .plots .plot import make_batch_plot
2525from anomstack .sql .read import read_sql
2626
27- ANOMSTACK_MAX_RUNTIME_SECONDS_TAG = os .getenv ("ANOMSTACK_MAX_RUNTIME_SECONDS_TAG" , 3600 )
27+ ANOMSTACK_MAX_RUNTIME_SECONDS_TAG = os .getenv (
28+ "ANOMSTACK_MAX_RUNTIME_SECONDS_TAG" , 3600
29+ )
2830
2931
3032def build_plot_job (spec : dict ) -> JobDefinition :
@@ -37,7 +39,6 @@ def build_plot_job(spec: dict) -> JobDefinition:
3739 JobDefinition: The plot job definition.
3840 """
3941
40-
4142 if spec .get ("disable_plot" ):
4243
4344 @job (
Original file line number Diff line number Diff line change 22Some helper functions for plotting.
33"""
44
5+ import matplotlib .dates as mdates
56import matplotlib .pyplot as plt
67import pandas as pd
78import seaborn as sns
89from matplotlib .figure import Figure
10+ from matplotlib .ticker import MaxNLocator
911
1012
1113def make_alert_plot (
@@ -101,6 +103,7 @@ def make_batch_plot(df: pd.DataFrame) -> plt.Figure:
101103 Returns:
102104 plt.Figure: The generated batch plot figure.
103105 """
106+ df ['metric_timestamp' ] = pd .to_datetime (df ['metric_timestamp' ])
104107 unique_metrics = df ["metric_name" ].unique ()
105108 colors = sns .color_palette ("viridis" , len (unique_metrics ))
106109
@@ -123,11 +126,14 @@ def make_batch_plot(df: pd.DataFrame) -> plt.Figure:
123126 label = "Metric Value" ,
124127 color = colors [i ],
125128 ax = ax1 ,
126- legend = True ,
129+ legend = False ,
127130 )
128131 ax1 .set_ylabel ("Metric Value" )
129132 ax1 .tick_params (axis = "y" , labelcolor = colors [i ])
130133
134+ ax1 .xaxis .set_major_locator (MaxNLocator (nbins = 5 ))
135+ ax1 .xaxis .set_major_formatter (mdates .DateFormatter ("%Y-%m-%d %H:%M" ))
136+
131137 ax2 = ax1 .twinx ()
132138 sns .lineplot (
133139 data = metric_data ,
You can’t perform that action at this time.
0 commit comments