Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -167,25 +167,12 @@ def _nice_tick0(xmin: float, step: int = 100) -> float:
|
|
| 167 |
return step * math.floor(xmin / step)
|
| 168 |
|
| 169 |
# ---------- Plot builders ----------
|
| 170 |
-
def _nice_step(lo: float, hi: float, target_ticks: int = 6) -> float:
|
| 171 |
-
"""Choose a pleasant dtick so labels look nice and consistent."""
|
| 172 |
-
rng = max(hi - lo, 1.0)
|
| 173 |
-
raw = rng / max(target_ticks, 1)
|
| 174 |
-
mag = 10 ** math.floor(math.log10(raw))
|
| 175 |
-
for m in [1, 2, 2.5, 5, 10]:
|
| 176 |
-
step = m * mag
|
| 177 |
-
if raw <= step:
|
| 178 |
-
return step
|
| 179 |
-
return mag * 10
|
| 180 |
-
|
| 181 |
def cross_plot(actual, pred):
|
| 182 |
a = pd.Series(actual).astype(float)
|
| 183 |
p = pd.Series(pred).astype(float)
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 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 |
|
|
@@ -196,8 +183,9 @@ def cross_plot(actual, pred):
|
|
| 196 |
showlegend=False
|
| 197 |
))
|
| 198 |
|
|
|
|
| 199 |
fig.add_trace(go.Scatter(
|
| 200 |
-
x=[
|
| 201 |
line=dict(color=COLORS["ref"], width=1.2, dash="dash"),
|
| 202 |
hoverinfo="skip", showlegend=False
|
| 203 |
))
|
|
@@ -207,21 +195,22 @@ def cross_plot(actual, pred):
|
|
| 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 |
-
#
|
| 214 |
fig.update_xaxes(
|
| 215 |
title_text="<b>Actual UCS (psi)</b>",
|
| 216 |
-
range=[
|
| 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=[
|
| 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
|
|
@@ -231,6 +220,8 @@ def cross_plot(actual, pred):
|
|
| 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:
|
|
|
|
| 167 |
return step * math.floor(xmin / step)
|
| 168 |
|
| 169 |
# ---------- Plot builders ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
def cross_plot(actual, pred):
|
| 171 |
a = pd.Series(actual).astype(float)
|
| 172 |
p = pd.Series(pred).astype(float)
|
| 173 |
|
| 174 |
+
fixed_min = 6000
|
| 175 |
+
fixed_max = 10000
|
|
|
|
|
|
|
| 176 |
|
| 177 |
fig = go.Figure()
|
| 178 |
|
|
|
|
| 183 |
showlegend=False
|
| 184 |
))
|
| 185 |
|
| 186 |
+
# Diagonal reference line (45°)
|
| 187 |
fig.add_trace(go.Scatter(
|
| 188 |
+
x=[fixed_min, fixed_max], y=[fixed_min, fixed_max], mode="lines",
|
| 189 |
line=dict(color=COLORS["ref"], width=1.2, dash="dash"),
|
| 190 |
hoverinfo="skip", showlegend=False
|
| 191 |
))
|
|
|
|
| 195 |
paper_bgcolor="#fff", plot_bgcolor="#fff",
|
| 196 |
margin=dict(l=64, r=18, t=10, b=48),
|
| 197 |
hovermode="closest",
|
| 198 |
+
font=dict(size=FONT_SZ),
|
| 199 |
+
dragmode="zoom", # enables box zoom
|
| 200 |
)
|
| 201 |
|
| 202 |
+
# Apply fixed range and identical ticks
|
| 203 |
fig.update_xaxes(
|
| 204 |
title_text="<b>Actual UCS (psi)</b>",
|
| 205 |
+
range=[fixed_min, fixed_max],
|
| 206 |
+
tickformat=",.0f", ticks="outside",
|
| 207 |
showline=True, linewidth=1.2, linecolor="#444", mirror=True,
|
| 208 |
showgrid=True, gridcolor="rgba(0,0,0,0.12)", automargin=True
|
| 209 |
)
|
| 210 |
fig.update_yaxes(
|
| 211 |
title_text="<b>Predicted UCS (psi)</b>",
|
| 212 |
+
range=[fixed_min, fixed_max],
|
| 213 |
+
tickformat=",.0f", ticks="outside",
|
| 214 |
showline=True, linewidth=1.2, linecolor="#444", mirror=True,
|
| 215 |
showgrid=True, gridcolor="rgba(0,0,0,0.12)",
|
| 216 |
scaleanchor="x", scaleratio=1, automargin=True
|
|
|
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
+
|
| 224 |
+
|
| 225 |
def track_plot(df, include_actual=True):
|
| 226 |
depth_col = next((c for c in df.columns if 'depth' in str(c).lower()), None)
|
| 227 |
if depth_col is not None:
|