UCS2014 commited on
Commit
0022378
·
verified ·
1 Parent(s): abb9cf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -32
app.py CHANGED
@@ -27,8 +27,8 @@ COLORS = {"pred": "#1f77b4", "actual": "#f2b702", "ref": "#5a5a5a"}
27
  CROSS_W = 500; CROSS_H = 500 # square cross-plot (Build + Validate)
28
  TRACK_W = 400; TRACK_H = 950 # log-strip style (all pages)
29
  FONT_SZ = 15
30
- PLOT_COLS = [30, 1, 8] # 3-column band: left • spacer • right (Build + Validate)
31
- CROSS_NUDGE = 0.5 # push cross-plot to the RIGHT inside its band:
32
  # inner columns [CROSS_NUDGE : 1] → bigger = more right
33
 
34
  # =========================
@@ -182,59 +182,55 @@ def cross_plot(actual, pred):
182
  a = pd.Series(actual).astype(float)
183
  p = pd.Series(pred).astype(float)
184
 
185
- # Common min/max for BOTH axes (with a tiny pad)
186
- lo = float(np.nanmin([a.min(), p.min()]))
187
- hi = float(np.nanmax([a.max(), p.max()]))
188
- pad = 0.03 * (hi - lo if hi > lo else 1.0)
189
- lo -= pad
190
- hi += pad
191
-
192
- # Fixed tick spacing for BOTH axes
193
- step = _nice_step(lo, hi, target_ticks=6)
194
- tick0 = step * math.floor(lo / step)
195
 
196
  fig = go.Figure()
 
197
  fig.add_trace(go.Scatter(
198
  x=a, y=p, mode="markers",
199
  marker=dict(size=6, color=COLORS["pred"]),
200
  hovertemplate="Actual: %{x:.0f}<br>Pred: %{y:.0f}<extra></extra>",
201
  showlegend=False
202
  ))
203
- # 45° reference
204
  fig.add_trace(go.Scatter(
205
- x=[lo, hi], y=[lo, hi],
206
- mode="lines", line=dict(color=COLORS["ref"], width=1.2, dash="dash"),
207
  hoverinfo="skip", showlegend=False
208
  ))
209
 
210
- # Identical range & ticks to BOTH axes
 
 
 
 
 
 
 
 
211
  fig.update_xaxes(
212
- range=[lo, hi],
213
- tickmode="linear", tick0=tick0, dtick=step,
214
- #fixedrange=True, # remove this if you want zooming
215
  showline=True, linewidth=1.2, linecolor="#444", mirror=True,
216
- showgrid=True, gridcolor="rgba(0,0,0,0.12)",
217
- title_text="<b>Actual UCS (psi)</b>"
218
  )
219
  fig.update_yaxes(
220
- range=[lo, hi],
221
- tickmode="linear", tick0=tick0, dtick=step,
222
- #fixedrange=True, # remove this if you want zooming
223
  showline=True, linewidth=1.2, linecolor="#444", mirror=True,
224
  showgrid=True, gridcolor="rgba(0,0,0,0.12)",
225
- scaleanchor="x", scaleratio=1,
226
- title_text="<b>Predicted UCS (psi)</b>"
227
  )
228
 
229
- fig.update_layout(
230
- width=CROSS_W, height=CROSS_H,
231
- paper_bgcolor="#fff", plot_bgcolor="#fff",
232
- margin=dict(l=64, r=18, t=10, b=48), hovermode="closest",
233
- font=dict(size=FONT_SZ)
234
- )
235
  return fig
236
 
237
 
 
238
  def track_plot(df, include_actual=True):
239
  depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
240
  if depth_col is not None:
 
27
  CROSS_W = 500; CROSS_H = 500 # square cross-plot (Build + Validate)
28
  TRACK_W = 400; TRACK_H = 950 # log-strip style (all pages)
29
  FONT_SZ = 15
30
+ PLOT_COLS = [30, 1, 10] # 3-column band: left • spacer • right (Build + Validate)
31
+ CROSS_NUDGE = 0.1 # push cross-plot to the RIGHT inside its band:
32
  # inner columns [CROSS_NUDGE : 1] → bigger = more right
33
 
34
  # =========================
 
182
  a = pd.Series(actual).astype(float)
183
  p = pd.Series(pred).astype(float)
184
 
185
+ # Get global min/max across both actual and predicted
186
+ all_vals = pd.concat([a, p])
187
+ lo = float(np.floor(all_vals.min() / 100) * 100)
188
+ hi = float(np.ceil(all_vals.max() / 100) * 100)
 
 
 
 
 
 
189
 
190
  fig = go.Figure()
191
+
192
  fig.add_trace(go.Scatter(
193
  x=a, y=p, mode="markers",
194
  marker=dict(size=6, color=COLORS["pred"]),
195
  hovertemplate="Actual: %{x:.0f}<br>Pred: %{y:.0f}<extra></extra>",
196
  showlegend=False
197
  ))
198
+
199
  fig.add_trace(go.Scatter(
200
+ x=[lo, hi], y=[lo, hi], mode="lines",
201
+ line=dict(color=COLORS["ref"], width=1.2, dash="dash"),
202
  hoverinfo="skip", showlegend=False
203
  ))
204
 
205
+ fig.update_layout(
206
+ width=CROSS_W, height=CROSS_H,
207
+ paper_bgcolor="#fff", plot_bgcolor="#fff",
208
+ margin=dict(l=64, r=18, t=10, b=48),
209
+ hovermode="closest",
210
+ font=dict(size=FONT_SZ)
211
+ )
212
+
213
+ # Set same range and ticks for both axes
214
  fig.update_xaxes(
215
+ title_text="<b>Actual UCS (psi)</b>",
216
+ range=[lo, hi], tickformat=",.0f",
217
+ ticks="outside",
218
  showline=True, linewidth=1.2, linecolor="#444", mirror=True,
219
+ showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
 
220
  )
221
  fig.update_yaxes(
222
+ title_text="<b>Predicted UCS (psi)</b>",
223
+ range=[lo, hi], tickformat=",.0f",
224
+ ticks="outside",
225
  showline=True, linewidth=1.2, linecolor="#444", mirror=True,
226
  showgrid=True, gridcolor="rgba(0,0,0,0.12)",
227
+ scaleanchor="x", scaleratio=1, automargin=True
 
228
  )
229
 
 
 
 
 
 
 
230
  return fig
231
 
232
 
233
+
234
  def track_plot(df, include_actual=True):
235
  depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
236
  if depth_col is not None: