Update matplotlib to 3.9.x

The mpl.cm toplevel registration has been removed.

https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html#top-level-cmap-registration-and-access-functions-in-mpl-cm
This commit is contained in:
Martin Weinelt 2024-07-07 14:23:29 +02:00
parent 188a7de467
commit 7d0ba3fd92
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
3 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ Flask_Limiter == 3.7.*
imutils == 0.5.*
joserfc == 0.11.*
markupsafe == 2.1.*
matplotlib == 3.8.*
matplotlib == 3.9.*
mypy == 1.6.1
numpy == 1.26.*
onvif_zeep == 0.2.12

View File

@ -1033,7 +1033,7 @@ class CameraConfig(FrigateBaseModel):
def __init__(self, **config):
# Set zone colors
if "zones" in config:
colors = plt.cm.get_cmap("tab10", len(config["zones"]))
colors = plt.colormaps["tab10"].resampled(len(config["zones"]))
config["zones"] = {
name: {**z, "color": tuple(round(255 * c) for c in colors(idx)[:3])}
for idx, (name, z) in enumerate(config["zones"].items())

View File

@ -128,7 +128,7 @@ class ModelConfig(BaseModel):
def create_colormap(self, enabled_labels: set[str]) -> None:
"""Get a list of colors for enabled labels."""
cmap = plt.cm.get_cmap("tab10", len(enabled_labels))
cmap = plt.colormaps["tab10"].resampled(len(enabled_labels))
for key, val in enumerate(enabled_labels):
self._colormap[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])