From 41e9fd31b8700abf2fb46166b800b6e0ac3deb57 Mon Sep 17 00:00:00 2001 From: mtryan83 Date: Fri, 8 Nov 2024 14:00:12 -0800 Subject: [PATCH 1/2] Update matplotlib.py to use .get_next_color At some point between matplotlib 2.1 and 3.9, ax._get_lines.prop_cycler was removed. The recommended replacement (per https://stackoverflow.com/a/78938755) is to use ax._get_lines.get_next_color(). Implemented with a try/except to hopefully support both. --- src/hapsira/plotting/orbit/backends/matplotlib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hapsira/plotting/orbit/backends/matplotlib.py b/src/hapsira/plotting/orbit/backends/matplotlib.py index 1f489bab9..4ed882bc8 100644 --- a/src/hapsira/plotting/orbit/backends/matplotlib.py +++ b/src/hapsira/plotting/orbit/backends/matplotlib.py @@ -69,8 +69,12 @@ def _get_colors(self, color, trail): """ if color is None: - # HACK: https://stackoverflow.com/a/13831816/554319 - color = next(self.ax._get_lines.prop_cycler)["color"] + try: + # Updated HACK, see https://stackoverflow.com/a/78938755 + color = ax._get_lines.get_next_color() + except AttributeError: + # HACK: https://stackoverflow.com/a/13831816/554319 + color = next(self.ax._get_lines.prop_cycler)["color"] colors = [color, to_rgba(color, 0)] if trail else [color] return colors From f2a315796d664e103bc86ed891f13be4e8687372 Mon Sep 17 00:00:00 2001 From: mtryan83 Date: Fri, 8 Nov 2024 14:33:38 -0800 Subject: [PATCH 2/2] Update matplotlib.py - forgot self in commit 41e9fd3 --- src/hapsira/plotting/orbit/backends/matplotlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hapsira/plotting/orbit/backends/matplotlib.py b/src/hapsira/plotting/orbit/backends/matplotlib.py index 4ed882bc8..629d1effc 100644 --- a/src/hapsira/plotting/orbit/backends/matplotlib.py +++ b/src/hapsira/plotting/orbit/backends/matplotlib.py @@ -71,7 +71,7 @@ def _get_colors(self, color, trail): if color is None: try: # Updated HACK, see https://stackoverflow.com/a/78938755 - color = ax._get_lines.get_next_color() + color = self.ax._get_lines.get_next_color() except AttributeError: # HACK: https://stackoverflow.com/a/13831816/554319 color = next(self.ax._get_lines.prop_cycler)["color"]