Skip to content

Commit 961c866

Browse files
Merge pull request #10 from UnravelSports/feat/pressing-intensity
fix mpl
2 parents 71b8161 + 7a603c8 commit 961c866

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

examples/pressing_intensity.ipynb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@
8989
"# %pip install unravelsports --quiet"
9090
]
9191
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"You might need to `pip install ffmpeg mplsoccer matplotlib seaborn` for this to work."
97+
]
98+
},
9299
{
93100
"cell_type": "markdown",
94101
"metadata": {},
@@ -508,9 +515,7 @@
508515
"source": [
509516
"**Video**\n",
510517
"\n",
511-
"Finally, we render our 35 second video using `FuncAnimation` and `mplsoccer`.\n",
512-
"\n",
513-
"You might need to `pip install ffmpeg` for this to work."
518+
"Finally, we render our 35 second video using `FuncAnimation` and `mplsoccer`."
514519
]
515520
},
516521
{

unravel/soccer/models/pressing_intensity.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
Constant,
1414
)
1515

16-
from mplsoccer import VerticalPitch, Pitch
17-
from matplotlib.axes import Axes
18-
from matplotlib.figure import Figure
19-
2016
from .utils import time_to_intercept, probability_to_intercept
2117

2218

unravel/utils/display/colors.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import re
55

6-
from matplotlib.colors import LinearSegmentedColormap
7-
86

97
@dataclass
108
class Color:
@@ -72,5 +70,26 @@ class GameColors:
7270

7371
@dataclass
7472
class ColorMaps:
75-
YELLOW_RED = LinearSegmentedColormap.from_list("", YlRd)
76-
YELLOW_RED_R = LinearSegmentedColormap.from_list("", list(reversed(YlRd)))
73+
_YlRd = ["#FFFF00", "#FF0000"] # Replace with actual YlRd values
74+
75+
@property
76+
def YELLOW_RED(self):
77+
try:
78+
from matplotlib.colors import LinearSegmentedColormap
79+
80+
return LinearSegmentedColormap.from_list("", self._YlRd)
81+
except ImportError:
82+
raise ImportError(
83+
"Seems like you don't have matplotlib installed. Please install it using: pip install matplotlib"
84+
)
85+
86+
@property
87+
def YELLOW_RED_R(self):
88+
try:
89+
from matplotlib.colors import LinearSegmentedColormap
90+
91+
return LinearSegmentedColormap.from_list("", list(reversed(self._YlRd)))
92+
except ImportError:
93+
raise ImportError(
94+
"Seems like you don't have matplotlib installed. Please install it using: pip install matplotlib"
95+
)

0 commit comments

Comments
 (0)