Skip to content

Commit

Permalink
Merge pull request #10 from UnravelSports/feat/pressing-intensity
Browse files Browse the repository at this point in the history
fix mpl
  • Loading branch information
UnravelSports authored Feb 15, 2025
2 parents 71b8161 + 7a603c8 commit 961c866
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
11 changes: 8 additions & 3 deletions examples/pressing_intensity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
"# %pip install unravelsports --quiet"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You might need to `pip install ffmpeg mplsoccer matplotlib seaborn` for this to work."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -508,9 +515,7 @@
"source": [
"**Video**\n",
"\n",
"Finally, we render our 35 second video using `FuncAnimation` and `mplsoccer`.\n",
"\n",
"You might need to `pip install ffmpeg` for this to work."
"Finally, we render our 35 second video using `FuncAnimation` and `mplsoccer`."
]
},
{
Expand Down
4 changes: 0 additions & 4 deletions unravel/soccer/models/pressing_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
Constant,
)

from mplsoccer import VerticalPitch, Pitch
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from .utils import time_to_intercept, probability_to_intercept


Expand Down
27 changes: 23 additions & 4 deletions unravel/utils/display/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import re

from matplotlib.colors import LinearSegmentedColormap


@dataclass
class Color:
Expand Down Expand Up @@ -72,5 +70,26 @@ class GameColors:

@dataclass
class ColorMaps:
YELLOW_RED = LinearSegmentedColormap.from_list("", YlRd)
YELLOW_RED_R = LinearSegmentedColormap.from_list("", list(reversed(YlRd)))
_YlRd = ["#FFFF00", "#FF0000"] # Replace with actual YlRd values

@property
def YELLOW_RED(self):
try:
from matplotlib.colors import LinearSegmentedColormap

return LinearSegmentedColormap.from_list("", self._YlRd)
except ImportError:
raise ImportError(
"Seems like you don't have matplotlib installed. Please install it using: pip install matplotlib"
)

@property
def YELLOW_RED_R(self):
try:
from matplotlib.colors import LinearSegmentedColormap

return LinearSegmentedColormap.from_list("", list(reversed(self._YlRd)))
except ImportError:
raise ImportError(
"Seems like you don't have matplotlib installed. Please install it using: pip install matplotlib"
)

0 comments on commit 961c866

Please sign in to comment.