Skip to content

Commit c5b88af

Browse files
profiler: fix minor plotting issue
* Plot legends could contain a partial list of the lines plotted if some of the lines were partial.
1 parent 46e44eb commit c5b88af

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

cylc/flow/main_loop/log_data_store.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,17 @@ def _plot(state, path):
107107
ax1.set_xlabel('Time (s)')
108108

109109
ax1.set_ylabel('Objects')
110-
for key, objects in state['objects'].items():
111-
ax1.plot(times, objects, label=key)
110+
lines = [
111+
ax1.plot(times, objects, label=key)[0]
112+
for key, objects in state['objects'].items()
113+
]
112114

113115
ax2 = ax1.twinx()
114116
ax2.set_ylabel('Size (kb)')
115117
for sizes in state['size'].values():
116118
ax2.plot(times, [x / 1000 for x in sizes], linestyle=':')
117119

118-
ax1.legend(loc=0)
120+
ax1.legend(lines, state['objects'], loc=0)
119121
ax2.legend(
120122
(ax1.get_children()[0], ax2.get_children()[0]),
121123
('objects', 'size'),

cylc/flow/main_loop/log_memory.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def _dump(data, path):
155155

156156
def _plot(fields, times, path, title='Objects'):
157157
if (
158-
not PLT
159-
or len(times) < 2
158+
not PLT
159+
or len(times) < 2
160160
):
161161
return False
162162

@@ -166,10 +166,12 @@ def _plot(fields, times, path, title='Objects'):
166166
ax1.set_xlabel('Time (s)')
167167
ax1.set_ylabel('Memory (kb)')
168168

169-
for key, sizes in fields.items():
170-
ax1.plot(times, [x / 1000 for x in sizes], label=key)
169+
lines = [
170+
ax1.plot(times, [x / 1000 for x in sizes], label=key)[0]
171+
for key, sizes in fields.items()
172+
]
171173

172-
ax1.legend(loc=0)
174+
ax1.legend(lines, fields, loc=0)
173175

174176
# start both axis at 0
175177
ax1.set_xlim(0, ax1.get_xlim()[1])

0 commit comments

Comments
 (0)