Skip to content

Commit

Permalink
Update matplotlib.py to use .get_next_color
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtryan83 authored Nov 8, 2024
1 parent 5d25e62 commit 41e9fd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hapsira/plotting/orbit/backends/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41e9fd3

Please sign in to comment.