UCS2014 commited on
Commit
eef4094
·
verified ·
1 Parent(s): d944491

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -26,13 +26,13 @@ MODEL_FALLBACKS = [MODELS_DIR / "model.joblib", MODELS_DIR / "model.pkl"]
26
  COLORS = {"pred": "#1f77b4", "actual": "#f2b702", "ref": "#5a5a5a"}
27
 
28
  # ---- Plot sizing controls ----
29
- CROSS_W = 300 # Matplotlib cross-plot width (in px) — None -> fallback used in fn
30
- CROSS_H = 300
31
- TRACK_W = 380 # Plotly track width in px (kept modest to avoid overlap)
32
- TRACK_H = 820
33
- FONT_SZ = 15
34
- PLOT_COLS = [1.5, 0.1, 1] # left • spacer • right
35
- CROSS_NUDGE = 0.0 # set >0 to shove cross-plot inward with a small left pad column
36
 
37
  # =========================
38
  # Page / CSS
@@ -172,14 +172,16 @@ def cross_plot_static(actual, pred):
172
  fixed_min, fixed_max = 6000, 10000
173
  ticks = np.arange(fixed_min, fixed_max + 1, 1000)
174
 
 
 
175
  fig, ax = plt.subplots(
176
- figsize=((CROSS_W or 500)/100, (CROSS_H or 420)/100),
177
- dpi=100,
178
  constrained_layout=False
179
  )
180
 
181
  # points
182
- ax.scatter(a, p, s=18, c=COLORS["pred"], alpha=0.9, linewidths=0)
183
 
184
  # 1:1 diagonal
185
  ax.plot([fixed_min, fixed_max], [fixed_min, fixed_max],
@@ -191,7 +193,7 @@ def cross_plot_static(actual, pred):
191
  ax.set_xticks(ticks)
192
  ax.set_yticks(ticks)
193
 
194
- # equal aspect → true 45° reference
195
  ax.set_aspect("equal", adjustable="box")
196
 
197
  # thousands formatting
@@ -199,20 +201,22 @@ def cross_plot_static(actual, pred):
199
  ax.xaxis.set_major_formatter(fmt)
200
  ax.yaxis.set_major_formatter(fmt)
201
 
202
- # labels (bold, larger)
203
- ax.set_xlabel("Actual UCS (psi)", fontweight="bold", fontsize=16)
204
- ax.set_ylabel("Predicted UCS (psi)", fontweight="bold", fontsize=16)
 
205
 
206
  # grid & frame
207
- ax.grid(True, linestyle=":", alpha=0.35)
208
  for spine in ax.spines.values():
209
- spine.set_linewidth(1.2)
210
  spine.set_color("#444")
211
 
212
- # extra room for the large labels
213
- fig.subplots_adjust(left=0.23, bottom=0.20, right=0.98, top=0.98)
214
  return fig
215
 
 
216
  # =========================
217
  # Track plot (Plotly)
218
  # =========================
 
26
  COLORS = {"pred": "#1f77b4", "actual": "#f2b702", "ref": "#5a5a5a"}
27
 
28
  # ---- Plot sizing controls ----
29
+ CROSS_W = 420 # px (explicit, not None)
30
+ CROSS_H = 420 # px
31
+ TRACK_W = 320 # px (slightly narrower to avoid crowding)
32
+ TRACK_H = 740 # px
33
+ FONT_SZ = 13
34
+ PLOT_COLS = [36, 6, 28] # wider spacer so plots never bump into each other
35
+ CROSS_NUDGE = 0.0 # keep 0 unless you really want an inner pad
36
 
37
  # =========================
38
  # Page / CSS
 
172
  fixed_min, fixed_max = 6000, 10000
173
  ticks = np.arange(fixed_min, fixed_max + 1, 1000)
174
 
175
+ # fixed px size = (figsize * dpi)
176
+ dpi = 110
177
  fig, ax = plt.subplots(
178
+ figsize=(CROSS_W / dpi, CROSS_H / dpi),
179
+ dpi=dpi,
180
  constrained_layout=False
181
  )
182
 
183
  # points
184
+ ax.scatter(a, p, s=16, c=COLORS["pred"], alpha=0.9, linewidths=0)
185
 
186
  # 1:1 diagonal
187
  ax.plot([fixed_min, fixed_max], [fixed_min, fixed_max],
 
193
  ax.set_xticks(ticks)
194
  ax.set_yticks(ticks)
195
 
196
+ # equal aspect → true 45°
197
  ax.set_aspect("equal", adjustable="box")
198
 
199
  # thousands formatting
 
201
  ax.xaxis.set_major_formatter(fmt)
202
  ax.yaxis.set_major_formatter(fmt)
203
 
204
+ # labels + ticks (smaller so they don't dominate)
205
+ ax.set_xlabel("Actual UCS (psi)", fontweight="bold", fontsize=12)
206
+ ax.set_ylabel("Predicted UCS (psi)", fontweight="bold", fontsize=12)
207
+ ax.tick_params(labelsize=10)
208
 
209
  # grid & frame
210
+ ax.grid(True, linestyle=":", alpha=0.3)
211
  for spine in ax.spines.values():
212
+ spine.set_linewidth(1.1)
213
  spine.set_color("#444")
214
 
215
+ # moderate margins; keeps labels readable but not huge
216
+ fig.subplots_adjust(left=0.16, bottom=0.16, right=0.98, top=0.98)
217
  return fig
218
 
219
+
220
  # =========================
221
  # Track plot (Plotly)
222
  # =========================