try to support old matplotlib

This commit is contained in:
Sylvestre Ledru 2024-09-01 12:10:03 +02:00
parent 5b03b5674a
commit 49c2994a02

View File

@ -309,7 +309,11 @@ def generate_graph(time_range):
mem_subplot.set_yticks(range(0, limit + 1, math.ceil(limit / 8)))
mem_subplot.grid(True)
colors = list(matplotlib.colormaps['tab20c'].colors * 100)
# Try to use the newer colormaps attribute; if not available, fallback
try:
colors = list(matplotlib.colormaps['tab20c'].colors * 100)
except AttributeError:
colors = list(plt.cm.get_cmap('tab20c').colors * 100)
for name, color in special_processes.items():
if name in process_name_map:
colors[process_name_map[name]] = color