UCS2014 commited on
Commit
2044ec2
·
verified ·
1 Parent(s): eec8bef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -28
app.py CHANGED
@@ -30,6 +30,7 @@ CROSS_W = 450 # px (matplotlib figure size; Streamlit will still scale)
30
  CROSS_H = 450
31
  TRACK_H = 740 # px (plotly height; width auto-fits column)
32
  FONT_SZ = 13
 
33
 
34
  # =========================
35
  # Page / CSS
@@ -199,7 +200,12 @@ def cross_plot_static(actual, pred):
199
  # =========================
200
  # Track plot (Plotly)
201
  # =========================
202
- def track_plot(df, include_actual=True):
 
 
 
 
 
203
  depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
204
  if depth_col is not None:
205
  y = pd.Series(df[depth_col]).astype(float)
@@ -224,18 +230,18 @@ def track_plot(df, include_actual=True):
224
  x=df["UCS_Pred"], y=y, mode="lines",
225
  line=dict(color=COLORS["pred"], width=1.8),
226
  name="UCS_Pred",
227
- hovertemplate="UCS_Pred: %{x:.0f}<br>"+ylab+": %{y}<extra></extra>"
228
  ))
229
  if include_actual and TARGET in df.columns:
230
  fig.add_trace(go.Scatter(
231
  x=df[TARGET], y=y, mode="lines",
232
  line=dict(color=COLORS["actual"], width=2.0, dash="dot"),
233
  name="UCS (actual)",
234
- hovertemplate="UCS (actual): %{x:.0f}<br>"+ylab+": %{y}<extra></extra>"
235
  ))
236
 
237
  fig.update_layout(
238
- height=TRACK_H, width=None, # width automatically fits the column
239
  paper_bgcolor="#fff", plot_bgcolor="#fff",
240
  margin=dict(l=64, r=16, t=36, b=48), hovermode="closest",
241
  font=dict(size=FONT_SZ),
@@ -245,33 +251,35 @@ def track_plot(df, include_actual=True):
245
  ),
246
  legend_title_text=""
247
  )
248
- BOLD = "Arial Black, Arial, sans-serif" # or "Open Sans Bold", "Helvetica Neue", etc.
249
-
250
- fig.update_xaxes(
251
- title_text="UCS (psi)",
252
- title_font=dict(size=16, family=BOLD), # ← bold axis title
253
- tickfont=dict(size=13, family=BOLD), # ← bold tick labels
254
- side="top",
255
- range=[xmin, xmax],
256
- ticks="outside",
257
- tickformat=",.0f",
258
- tickmode="auto",
259
- tick0=tick0,
260
- showline=True, linewidth=1.2, linecolor="#444", mirror=True,
261
- showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
262
- )
263
 
264
- fig.update_yaxes(
265
- title_text=ylab,
266
- title_font=dict(size=16, family=BOLD), # ← bold axis title
267
- tickfont=dict(size=13, family=BOLD), # ← bold tick labels
268
- range=y_range,
269
- ticks="outside",
270
- showline=True, linewidth=1.2, linecolor="#444", mirror=True,
271
- showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
272
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  return fig
274
 
 
275
  # ---------- Preview modal (matplotlib) ----------
276
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
277
  cols = [c for c in cols if c in df.columns]
 
30
  CROSS_H = 450
31
  TRACK_H = 740 # px (plotly height; width auto-fits column)
32
  FONT_SZ = 13
33
+ BOLD_FONT = "Arial Black, Arial, sans-serif" # used for bold axis titles & ticks
34
 
35
  # =========================
36
  # Page / CSS
 
200
  # =========================
201
  # Track plot (Plotly)
202
  # =========================
203
+
204
+ ticks="outside",
205
+ showline=True, linewidth=1.2, linecolor="#444", mirror=True,
206
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
207
+ )
208
+ return figdef track_plot(df, include_actual=True):
209
  depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
210
  if depth_col is not None:
211
  y = pd.Series(df[depth_col]).astype(float)
 
230
  x=df["UCS_Pred"], y=y, mode="lines",
231
  line=dict(color=COLORS["pred"], width=1.8),
232
  name="UCS_Pred",
233
+ hovertemplate="UCS_Pred: %{x:.0f}<br>" + ylab + ": %{y}<extra></extra>"
234
  ))
235
  if include_actual and TARGET in df.columns:
236
  fig.add_trace(go.Scatter(
237
  x=df[TARGET], y=y, mode="lines",
238
  line=dict(color=COLORS["actual"], width=2.0, dash="dot"),
239
  name="UCS (actual)",
240
+ hovertemplate="UCS (actual): %{x:.0f}<br>" + ylab + ": %{y}<extra></extra>"
241
  ))
242
 
243
  fig.update_layout(
244
+ height=TRACK_H, width=None, # width auto-fits the column
245
  paper_bgcolor="#fff", plot_bgcolor="#fff",
246
  margin=dict(l=64, r=16, t=36, b=48), hovermode="closest",
247
  font=dict(size=FONT_SZ),
 
251
  ),
252
  legend_title_text=""
253
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ # ✅ These must stay inside the function (properly indented)
256
+ fig.update_xaxes(
257
+ title_text="UCS (psi)",
258
+ title_font=dict(size=16, family=BOLD_FONT),
259
+ tickfont=dict(size=13, family=BOLD_FONT),
260
+ side="top",
261
+ range=[xmin, xmax],
262
+ ticks="outside",
263
+ tickformat=",.0f",
264
+ tickmode="auto",
265
+ tick0=tick0,
266
+ showline=True, linewidth=1.2, linecolor="#444", mirror=True,
267
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
268
+ )
269
+
270
+ fig.update_yaxes(
271
+ title_text=ylab,
272
+ title_font=dict(size=16, family=BOLD_FONT),
273
+ tickfont=dict(size=13, family=BOLD_FONT),
274
+ range=y_range,
275
+ ticks="outside",
276
+ showline=True, linewidth=1.2, linecolor="#444", mirror=True,
277
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
278
+ )
279
+
280
  return fig
281
 
282
+
283
  # ---------- Preview modal (matplotlib) ----------
284
  def preview_tracks(df: pd.DataFrame, cols: list[str]):
285
  cols = [c for c in cols if c in df.columns]