UCS2014 commited on
Commit
a514cb7
·
verified ·
1 Parent(s): f1da5d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -27
app.py CHANGED
@@ -242,15 +242,17 @@ def track_plot(df, include_actual=True):
242
  x_lo, x_hi = float(x_series.min()), float(x_series.max())
243
  x_pad = 0.03 * (x_hi - x_lo if x_hi > x_lo else 1.0)
244
  xmin, xmax = x_lo - x_pad, x_hi + x_pad
245
- tick0 = _nice_tick0(xmin, step=100) # sensible first tick at left border
246
 
247
  fig = go.Figure()
 
248
  fig.add_trace(go.Scatter(
249
  x=df["UCS_Pred"], y=y, mode="lines",
250
  line=dict(color=COLORS["pred"], width=1.8),
251
  name="UCS_Pred",
252
  hovertemplate="UCS_Pred: %{x:.0f}<br>"+ylab+": %{y}<extra></extra>"
253
  ))
 
254
  if include_actual and TARGET in df.columns:
255
  fig.add_trace(go.Scatter(
256
  x=df[TARGET], y=y, mode="lines",
@@ -260,8 +262,10 @@ def track_plot(df, include_actual=True):
260
  ))
261
 
262
  fig.update_layout(
263
- width=TRACK_W, height=TRACK_H, paper_bgcolor="#fff", plot_bgcolor="#fff",
264
- margin=dict(l=72, r=18, t=36, b=48), hovermode="closest",
 
 
265
  font=dict(size=FONT_SZ),
266
  legend=dict(
267
  x=0.98, y=0.05, xanchor="right", yanchor="bottom",
@@ -269,36 +273,38 @@ def track_plot(df, include_actual=True):
269
  ),
270
  legend_title_text=""
271
  )
272
- fig.update_xaxes(
273
- title_text="<b>UCS (psi)</b>",
274
- title_font=dict(size=16), # ⬅️ increase font size here
275
- side="top", range=[xmin, xmax],
276
- ticks="outside", tickformat=",.0f",
277
- tickmode="auto", tick0=tick0,
278
- showline=True, linewidth=1.2, linecolor="#444", mirror=True,
279
- showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
280
- )
281
 
282
- fig.update_yaxes(
283
- title_text=f"<b>{ylab}</b>",
284
- title_font=dict(size=16), # ⬅️ increase font size here
285
- range=y_range,
286
- ticks="outside",
287
- showline=True, linewidth=1.2, linecolor="#444", mirror=True,
288
- showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
289
- )
 
 
 
 
 
 
 
 
 
 
290
 
291
  # Add a border rectangle to enclose the full figure space
292
- fig.add_shape(
293
- type="rect",
294
- xref="paper", yref="paper",
295
- x0=0, y0=0, x1=1, y1=1, # full canvas
296
- line=dict(color="#000", width=1.5),
297
- layer="below"
298
- )
299
 
300
  return fig
301
 
 
302
  # ---------- Preview modal (matplotlib) ----------
303
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
304
  cols = [c for c in cols if c in df.columns]
 
242
  x_lo, x_hi = float(x_series.min()), float(x_series.max())
243
  x_pad = 0.03 * (x_hi - x_lo if x_hi > x_lo else 1.0)
244
  xmin, xmax = x_lo - x_pad, x_hi + x_pad
245
+ tick0 = _nice_tick0(xmin, step=100)
246
 
247
  fig = go.Figure()
248
+
249
  fig.add_trace(go.Scatter(
250
  x=df["UCS_Pred"], y=y, mode="lines",
251
  line=dict(color=COLORS["pred"], width=1.8),
252
  name="UCS_Pred",
253
  hovertemplate="UCS_Pred: %{x:.0f}<br>"+ylab+": %{y}<extra></extra>"
254
  ))
255
+
256
  if include_actual and TARGET in df.columns:
257
  fig.add_trace(go.Scatter(
258
  x=df[TARGET], y=y, mode="lines",
 
262
  ))
263
 
264
  fig.update_layout(
265
+ width=TRACK_W, height=TRACK_H,
266
+ paper_bgcolor="#fff", plot_bgcolor="#fff",
267
+ margin=dict(l=72, r=18, t=36, b=48),
268
+ hovermode="closest",
269
  font=dict(size=FONT_SZ),
270
  legend=dict(
271
  x=0.98, y=0.05, xanchor="right", yanchor="bottom",
 
273
  ),
274
  legend_title_text=""
275
  )
 
 
 
 
 
 
 
 
 
276
 
277
+ fig.update_xaxes(
278
+ title_text="<b>UCS (psi)</b>",
279
+ title_font=dict(size=16),
280
+ side="top", range=[xmin, xmax],
281
+ ticks="outside", tickformat=",.0f",
282
+ tickmode="auto", tick0=tick0,
283
+ showline=True, linewidth=1.2, linecolor="#444", mirror=True,
284
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
285
+ )
286
+
287
+ fig.update_yaxes(
288
+ title_text=f"<b>{ylab}</b>",
289
+ title_font=dict(size=16),
290
+ range=y_range,
291
+ ticks="outside",
292
+ showline=True, linewidth=1.2, linecolor="#444", mirror=True,
293
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
294
+ )
295
 
296
  # Add a border rectangle to enclose the full figure space
297
+ fig.add_shape(
298
+ type="rect",
299
+ xref="paper", yref="paper",
300
+ x0=0, y0=0, x1=1, y1=1,
301
+ line=dict(color="#000", width=1.5),
302
+ layer="below"
303
+ )
304
 
305
  return fig
306
 
307
+
308
  # ---------- Preview modal (matplotlib) ----------
309
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
310
  cols = [c for c in cols if c in df.columns]