Skip to content

Commit 0ce2b3d

Browse files
authored
Update client.py
1 parent 5120826 commit 0ce2b3d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

simvue/client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,35 @@ def get_metrics_multiple(self, runs, names, xaxis, sample_by=0, format='list'):
371371
return response.json()
372372

373373
raise Exception(response.text)
374+
375+
def plot_metrics(self, runs, names, xaxis, sample_by=0):
376+
"""
377+
Plot time series metrics from multiple runs and/or metrics
378+
"""
379+
data = self.get_metrics_multiple(runs, names, xaxis, sample_by, format='dataframe')
380+
381+
import matplotlib.pyplot as plt
382+
383+
for run in runs:
384+
for name in names:
385+
label = None
386+
if len(runs) > 1 and len(names) > 1:
387+
label = f"{run}: {name}"
388+
elif len(runs) > 1 and len(names) == 1:
389+
label = run
390+
elif len(runs) == 1 and len(names) > 1:
391+
label = name
392+
393+
plt.plot(data[(run, name, xaxis)],
394+
data[(run, name, 'value')],
395+
label=label)
396+
397+
if xaxis == 'step':
398+
plt.xlabel('steps')
399+
elif xaxis == 'time':
400+
plt.xlabel('relative time')
401+
402+
if len(names) == 1:
403+
plt.ylabel(names[0])
404+
405+
return plt

0 commit comments

Comments
 (0)