cyberosa commited on
Commit
88f9d70
·
1 Parent(s): dc66018

improving errors by mech layout

Browse files
Files changed (1) hide show
  1. tabs/error.py +20 -25
tabs/error.py CHANGED
@@ -130,31 +130,26 @@ def plot_week_error_data_by_market(error_df: pd.DataFrame, week: str) -> gr.Plot
130
 
131
  def plot_weekly_errors_by_mech(errors_by_mech: pd.DataFrame) -> gr.Plot:
132
  """Function to plot the weekly errors by mech address"""
133
- unique_mech_addresses = errors_by_mech["mech_address"].unique()
134
-
135
- for mech_address in unique_mech_addresses:
136
- # Filter the data for the current mech_address
137
- filtered_data = errors_by_mech[errors_by_mech["mech_address"] == mech_address]
138
-
139
- # Create the bar chart for the filtered data
140
- fig = px.bar(
141
- filtered_data,
142
- x="request_month_year_week",
143
- y="requests",
144
- color="error_cat",
145
- barmode="group",
146
- color_discrete_sequence=["green", "orange"],
147
- title=f"Error distribution for Mech Address: {mech_address}",
148
- labels={
149
- "requestmonthyearweek": "Month-Year-Week",
150
- "requests": "Number of Requests",
151
- "error_cat": "Error Category",
152
- "errors_percentage": "Percentage",
153
- },
154
- text="errors_percentage",
155
- height=HEIGHT,
156
- width=WIDTH,
157
- )
158
  fig.update_traces(
159
  texttemplate="%{y} (%{text:.2f}%)",
160
  textposition="outside",
 
130
 
131
  def plot_weekly_errors_by_mech(errors_by_mech: pd.DataFrame) -> gr.Plot:
132
  """Function to plot the weekly errors by mech address"""
133
+ fig = px.bar(
134
+ errors_by_mech,
135
+ x="request_month_year_week",
136
+ y="requests",
137
+ color="error_cat",
138
+ barmode="group",
139
+ color_discrete_sequence=["green", "orange"],
140
+ labels={
141
+ "requestmonthyearweek": "Month-Year-Week",
142
+ "requests": "Number of Requests",
143
+ "error_cat": "Error Category",
144
+ "errors_percentage": "Percentage",
145
+ },
146
+ text="errors_percentage",
147
+ height=600,
148
+ width=800,
149
+ facet_col="mech_address",
150
+ facet_col_spacing=0.5,
151
+ facet_col_wrap=1,
152
+ )
 
 
 
 
 
153
  fig.update_traces(
154
  texttemplate="%{y} (%{text:.2f}%)",
155
  textposition="outside",