Skip to content

Commit

Permalink
visualize difficulty/slope plots
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Jan 9, 2025
1 parent 4db686d commit 25fd133
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions openskistats/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ def ski_rose_the_world(min_combined_vertical: int = 10_000) -> None:
from openskistats.plot_runs import (
RunLatitudeBearingHistogram,
plot_bearing_by_latitude_bin,
plot_run_difficulty_histograms_by_slope,
)
from openskistats.plot_ski_areas import (
plot_ski_area_metric_ecdfs,
Expand All @@ -491,6 +492,12 @@ def ski_rose_the_world(min_combined_vertical: int = 10_000) -> None:
figures["latitude_histogram"] = (
RunLatitudeBearingHistogram().plot_latitude_histogram().draw()
)
figures["slope_by_difficulty_distributions_full"] = (
plot_run_difficulty_histograms_by_slope(condense_difficulty=False).draw()
)
figures["slope_by_difficulty_distributions_condensed"] = (
plot_run_difficulty_histograms_by_slope(condense_difficulty=True).draw()
)
lorenz_plot, gini_plot = plot_ski_area_metric_ecdfs()
figures["ski_area_lorenz_curves"] = lorenz_plot.draw()
figures["ski_area_gini_bars"] = gini_plot.draw()
Expand Down
5 changes: 3 additions & 2 deletions openskistats/plot_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
get_cut_bearing_bins_df,
)
from openskistats.models import SkiRunDifficulty
from openskistats.plot import NARROW_SPACE
from openskistats.utils import pl_flip_bearing, pl_hemisphere


Expand Down Expand Up @@ -347,7 +348,7 @@ def plot_run_difficulty_histograms_by_slope(
)
.with_columns(
label=pl.struct("runs_count", "combined_vertical").map_elements(
lambda x: f"{x['runs_count']:,} runs\n{x['combined_vertical'] / 1_000:,.0f} km vert",
lambda x: f"{x['runs_count']:,} runs\n{x['combined_vertical'] / 1_000:,.0f}{NARROW_SPACE}km vert",
return_dtype=pl.String,
)
)
Expand Down Expand Up @@ -384,12 +385,12 @@ def plot_run_difficulty_histograms_by_slope(
breaks=np.arange(0, 90, 10),
labels=lambda values: [f"{x:.0f}°" for x in values],
expand=(0, 0),
limits=(0, 42),
)
+ pn.scale_y_continuous(
name="Combined Vertical (km)",
labels=lambda values: [f"{x / 1_000:.0f}" for x in values],
)
+ pn.coord_cartesian(xlim=(0, 42))
+ pn.theme_bw()
+ pn.theme(
figure_size=(3, len(colormap)),
Expand Down

0 comments on commit 25fd133

Please sign in to comment.