diff --git a/examples/pressing_intensity.ipynb b/examples/pressing_intensity.ipynb index d3b2fc91..e7405cb1 100644 --- a/examples/pressing_intensity.ipynb +++ b/examples/pressing_intensity.ipynb @@ -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": {}, @@ -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`." ] }, { diff --git a/unravel/soccer/models/pressing_intensity.py b/unravel/soccer/models/pressing_intensity.py index 3ca6c9b3..3c79cd8e 100644 --- a/unravel/soccer/models/pressing_intensity.py +++ b/unravel/soccer/models/pressing_intensity.py @@ -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 diff --git a/unravel/utils/display/colors.py b/unravel/utils/display/colors.py index 83854236..601fd3c3 100644 --- a/unravel/utils/display/colors.py +++ b/unravel/utils/display/colors.py @@ -3,8 +3,6 @@ import re -from matplotlib.colors import LinearSegmentedColormap - @dataclass class Color: @@ -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" + )