Spaces:
Sleeping
Sleeping
Lode Nachtergaele
commited on
Commit
·
378169c
1
Parent(s):
b8232fa
again altair 5
Browse files- app.py +69 -69
- poetry.lock +8 -18
- pyproject.toml +1 -1
- requirements.txt +1 -1
app.py
CHANGED
@@ -182,92 +182,92 @@ def generate_height_profile_json(df: pd.DataFrame) -> str:
|
|
182 |
df["smoothed_grade_color"] = df["smoothed_grade"].map(grade_to_color)
|
183 |
# df["grade_color"] = df["grade"].map(grade_to_color)
|
184 |
|
185 |
-
# elevation = (
|
186 |
-
# alt.Chart(
|
187 |
-
# df[["distance_from_start", "smoothed_elevation", "smoothed_grade_color"]]
|
188 |
-
# )
|
189 |
-
# .mark_bar()
|
190 |
-
# .encode(
|
191 |
-
# x=alt.X("distance_from_start")
|
192 |
-
# .axis(
|
193 |
-
# grid=False,
|
194 |
-
# tickCount=10,
|
195 |
-
# labelExpr="datum.label + ' km'",
|
196 |
-
# title=None,
|
197 |
-
# )
|
198 |
-
# .scale(domain=(0, total_distance_round)),
|
199 |
-
# y=alt.Y("smoothed_elevation").axis(
|
200 |
-
# domain=False,
|
201 |
-
# ticks=False,
|
202 |
-
# tickCount=5,
|
203 |
-
# labelExpr="datum.label + ' m'",
|
204 |
-
# title=None,
|
205 |
-
# ),
|
206 |
-
# color=alt.Color("smoothed_grade_color").scale(None),
|
207 |
-
# )
|
208 |
-
# )
|
209 |
-
max_elevation = df["elev"].max().round(-1)
|
210 |
elevation = (
|
211 |
-
alt.Chart(
|
212 |
-
|
213 |
-
color=alt.Gradient(
|
214 |
-
gradient="linear",
|
215 |
-
stops=[
|
216 |
-
alt.GradientStop(color="lightgrey", offset=0),
|
217 |
-
alt.GradientStop(color="darkgrey", offset=1),
|
218 |
-
],
|
219 |
-
x1=1,
|
220 |
-
x2=1,
|
221 |
-
y1=1,
|
222 |
-
y2=0,
|
223 |
-
),
|
224 |
-
line={"color": "darkgreen"},
|
225 |
)
|
|
|
226 |
.encode(
|
227 |
-
x=alt.X(
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
ticks=False,
|
242 |
-
tickCount=5,
|
243 |
-
labelExpr="datum.label + ' m'",
|
244 |
-
),
|
245 |
-
scale=alt.Scale(domain=(0, max_elevation)),
|
246 |
),
|
|
|
247 |
)
|
248 |
)
|
249 |
-
|
250 |
-
#
|
251 |
-
# alt.Chart(
|
252 |
-
# .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
# .encode(
|
254 |
-
# x=alt.X(
|
255 |
-
#
|
256 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
# )
|
258 |
# )
|
|
|
259 |
line_peaks = (
|
260 |
alt.Chart(df_peaks_filtered[["distance_from_start", "elev", "max_elevation"]])
|
261 |
.mark_rule(color="red")
|
262 |
.encode(
|
263 |
-
x=alt.X(
|
264 |
-
"distance_from_start:Q",
|
265 |
-
scale=alt.Scale(domain=(0, total_distance_round)),
|
266 |
-
),
|
267 |
y="elev",
|
268 |
y2="max_elevation",
|
269 |
)
|
270 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
df_annot = (
|
272 |
df_peaks_filtered.reset_index(drop=True)
|
273 |
.assign(number=lambda df_: df_.index + 1)
|
|
|
182 |
df["smoothed_grade_color"] = df["smoothed_grade"].map(grade_to_color)
|
183 |
# df["grade_color"] = df["grade"].map(grade_to_color)
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
elevation = (
|
186 |
+
alt.Chart(
|
187 |
+
df[["distance_from_start", "smoothed_elevation", "smoothed_grade_color"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
)
|
189 |
+
.mark_bar()
|
190 |
.encode(
|
191 |
+
x=alt.X("distance_from_start")
|
192 |
+
.axis(
|
193 |
+
grid=False,
|
194 |
+
tickCount=10,
|
195 |
+
labelExpr="datum.label + ' km'",
|
196 |
+
title=None,
|
197 |
+
)
|
198 |
+
.scale(domain=(0, total_distance_round)),
|
199 |
+
y=alt.Y("smoothed_elevation").axis(
|
200 |
+
domain=False,
|
201 |
+
ticks=False,
|
202 |
+
tickCount=5,
|
203 |
+
labelExpr="datum.label + ' m'",
|
204 |
+
title=None,
|
|
|
|
|
|
|
|
|
|
|
205 |
),
|
206 |
+
color=alt.Color("smoothed_grade_color").scale(None),
|
207 |
)
|
208 |
)
|
209 |
+
max_elevation = df["elev"].max().round(-1)
|
210 |
+
# elevation = (
|
211 |
+
# alt.Chart(df)
|
212 |
+
# .mark_area(
|
213 |
+
# color=alt.Gradient(
|
214 |
+
# gradient="linear",
|
215 |
+
# stops=[
|
216 |
+
# alt.GradientStop(color="lightgrey", offset=0),
|
217 |
+
# alt.GradientStop(color="darkgrey", offset=1),
|
218 |
+
# ],
|
219 |
+
# x1=1,
|
220 |
+
# x2=1,
|
221 |
+
# y1=1,
|
222 |
+
# y2=0,
|
223 |
+
# ),
|
224 |
+
# line={"color": "darkgreen"},
|
225 |
+
# )
|
226 |
# .encode(
|
227 |
+
# x=alt.X(
|
228 |
+
# "distance_from_start",
|
229 |
+
# axis=alt.Axis(
|
230 |
+
# domain=False,
|
231 |
+
# ticks=False,
|
232 |
+
# tickCount=10,
|
233 |
+
# labelExpr="datum.label + ' km'",
|
234 |
+
# ),
|
235 |
+
# scale=alt.Scale(domain=(0, total_distance_round)),
|
236 |
+
# ),
|
237 |
+
# y=alt.Y(
|
238 |
+
# "elev",
|
239 |
+
# axis=alt.Axis(
|
240 |
+
# domain=False,
|
241 |
+
# ticks=False,
|
242 |
+
# tickCount=5,
|
243 |
+
# labelExpr="datum.label + ' m'",
|
244 |
+
# ),
|
245 |
+
# scale=alt.Scale(domain=(0, max_elevation)),
|
246 |
+
# ),
|
247 |
# )
|
248 |
# )
|
249 |
+
df_peaks_filtered = find_climbs(df)
|
250 |
line_peaks = (
|
251 |
alt.Chart(df_peaks_filtered[["distance_from_start", "elev", "max_elevation"]])
|
252 |
.mark_rule(color="red")
|
253 |
.encode(
|
254 |
+
x=alt.X("distance_from_start:Q").scale(domain=(0, total_distance_round)),
|
|
|
|
|
|
|
255 |
y="elev",
|
256 |
y2="max_elevation",
|
257 |
)
|
258 |
)
|
259 |
+
# line_peaks = (
|
260 |
+
# alt.Chart(df_peaks_filtered[["distance_from_start", "elev", "max_elevation"]])
|
261 |
+
# .mark_rule(color="red")
|
262 |
+
# .encode(
|
263 |
+
# x=alt.X(
|
264 |
+
# "distance_from_start:Q",
|
265 |
+
# scale=alt.Scale(domain=(0, total_distance_round)),
|
266 |
+
# ),
|
267 |
+
# y="elev",
|
268 |
+
# y2="max_elevation",
|
269 |
+
# )
|
270 |
+
# )
|
271 |
df_annot = (
|
272 |
df_peaks_filtered.reset_index(drop=True)
|
273 |
.assign(number=lambda df_: df_.index + 1)
|
poetry.lock
CHANGED
@@ -2,25 +2,26 @@
|
|
2 |
|
3 |
[[package]]
|
4 |
name = "altair"
|
5 |
-
version = "
|
6 |
-
description = "Altair: A declarative statistical visualization library for Python."
|
7 |
optional = false
|
8 |
python-versions = ">=3.7"
|
9 |
files = [
|
10 |
-
{file = "altair-
|
11 |
-
{file = "altair-
|
12 |
]
|
13 |
|
14 |
[package.dependencies]
|
15 |
-
entrypoints = "*"
|
16 |
jinja2 = "*"
|
17 |
jsonschema = ">=3.0"
|
18 |
numpy = "*"
|
19 |
pandas = ">=0.18"
|
20 |
toolz = "*"
|
|
|
21 |
|
22 |
[package.extras]
|
23 |
-
dev = ["black", "
|
|
|
24 |
|
25 |
[[package]]
|
26 |
name = "attrs"
|
@@ -277,17 +278,6 @@ files = [
|
|
277 |
{file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"},
|
278 |
]
|
279 |
|
280 |
-
[[package]]
|
281 |
-
name = "entrypoints"
|
282 |
-
version = "0.4"
|
283 |
-
description = "Discover and load entry points from installed packages."
|
284 |
-
optional = false
|
285 |
-
python-versions = ">=3.6"
|
286 |
-
files = [
|
287 |
-
{file = "entrypoints-0.4-py3-none-any.whl", hash = "sha256:f174b5ff827504fd3cd97cc3f8649f3693f51538c7e4bdf3ef002c8429d42f9f"},
|
288 |
-
{file = "entrypoints-0.4.tar.gz", hash = "sha256:b706eddaa9218a19ebcd67b56818f05bb27589b1ca9e8d797b74affad4ccacd4"},
|
289 |
-
]
|
290 |
-
|
291 |
[[package]]
|
292 |
name = "exceptiongroup"
|
293 |
version = "1.1.2"
|
@@ -1503,4 +1493,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
|
|
1503 |
[metadata]
|
1504 |
lock-version = "2.0"
|
1505 |
python-versions = ">=3.10,<3.13"
|
1506 |
-
content-hash = "
|
|
|
2 |
|
3 |
[[package]]
|
4 |
name = "altair"
|
5 |
+
version = "5.0.1"
|
6 |
+
description = "Vega-Altair: A declarative statistical visualization library for Python."
|
7 |
optional = false
|
8 |
python-versions = ">=3.7"
|
9 |
files = [
|
10 |
+
{file = "altair-5.0.1-py3-none-any.whl", hash = "sha256:9f3552ed5497d4dfc14cf48a76141d8c29ee56eae2873481b4b28134268c9bbe"},
|
11 |
+
{file = "altair-5.0.1.tar.gz", hash = "sha256:087d7033cb2d6c228493a053e12613058a5d47faf6a36aea3ff60305fd8b4cb0"},
|
12 |
]
|
13 |
|
14 |
[package.dependencies]
|
|
|
15 |
jinja2 = "*"
|
16 |
jsonschema = ">=3.0"
|
17 |
numpy = "*"
|
18 |
pandas = ">=0.18"
|
19 |
toolz = "*"
|
20 |
+
typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""}
|
21 |
|
22 |
[package.extras]
|
23 |
+
dev = ["black (<24)", "hatch", "ipython", "m2r", "mypy", "pandas-stubs", "pytest", "pytest-cov", "ruff", "types-jsonschema", "types-setuptools", "vega-datasets", "vl-convert-python"]
|
24 |
+
doc = ["docutils", "geopandas", "jinja2", "myst-parser", "numpydoc", "pillow", "pydata-sphinx-theme", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinxext-altair"]
|
25 |
|
26 |
[[package]]
|
27 |
name = "attrs"
|
|
|
278 |
{file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"},
|
279 |
]
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
[[package]]
|
282 |
name = "exceptiongroup"
|
283 |
version = "1.1.2"
|
|
|
1493 |
[metadata]
|
1494 |
lock-version = "2.0"
|
1495 |
python-versions = ">=3.10,<3.13"
|
1496 |
+
content-hash = "748a07a0f37a12766536420ac445825e1cabd04ca2fb89f4038c9dd55e1cd57b"
|
pyproject.toml
CHANGED
@@ -14,7 +14,7 @@ scipy = "1.11.1"
|
|
14 |
watchdog = "^3.0.0"
|
15 |
folium = "^0.14.0"
|
16 |
streamlit-folium = "^0.12.0"
|
17 |
-
altair = "
|
18 |
|
19 |
|
20 |
[tool.poetry.group.dev.dependencies]
|
|
|
14 |
watchdog = "^3.0.0"
|
15 |
folium = "^0.14.0"
|
16 |
streamlit-folium = "^0.12.0"
|
17 |
+
altair = "5.0.1"
|
18 |
|
19 |
|
20 |
[tool.poetry.group.dev.dependencies]
|
requirements.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# streamlit==1.24.0
|
2 |
folium==0.14.0
|
3 |
streamlit-folium==0.12.0
|
4 |
-
|
5 |
# pandas==2.0.3
|
6 |
scipy==1.11.1
|
|
|
1 |
# streamlit==1.24.0
|
2 |
folium==0.14.0
|
3 |
streamlit-folium==0.12.0
|
4 |
+
altair==5.0.1
|
5 |
# pandas==2.0.3
|
6 |
scipy==1.11.1
|