Skip to content

Commit c7a2601

Browse files
committed
Show legend for subprocess conditionally
1 parent 638e1a5 commit c7a2601

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

usage-wrapper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import threading
1010
import time
11+
from itertools import chain
1112

1213
try:
1314
import psutil
@@ -398,9 +399,10 @@ def generate_graph():
398399
custom_lines.append(Line2D([0], [0], color='green', lw=LW))
399400
custom_lines.append(Line2D([0], [0], color='red', lw=LW))
400401

401-
colors = special_processes.values()
402-
custom_lines += [Line2D([0], [0], color=x, lw=5) for x in colors]
403-
names += list(special_processes.keys())
402+
if sum(chain(*cpu_stacks)) > 0:
403+
colors = special_processes.values()
404+
custom_lines += [Line2D([0], [0], color=x, lw=5) for x in colors]
405+
names += list(special_processes.keys())
404406
fig.legend(custom_lines, names, loc='right', prop={'size': 6})
405407

406408
filename = args.output

0 commit comments

Comments
 (0)