Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
draw multiple lines in visdom
def draw_line(vis, step, lines, names):
# draw multiple lines in one panel.
"""
:param vis: the object of the visdom.Visdom
:param step: the step of the line
:param lines: the lines tuple, (line1, line2, ...)
:param names: the names tuple, (name1, name2, ...)
:return: None
"""
if not len(lines) == len(names):
raise ValueError('The length of the input is not the same')
win_name = ''
for i in range(len(names)):
win_name += names[i]
if step == 0:
for line, name in zip(lines, names):
vis.line(X=torch.Tensor([step]),
Y=torch.Tensor([line]),
win=win_name,
name='%s' % name,
opts=dict(legend=[name])
)
else:
for line, name in zip(lines, names):
vis.updateTrace(X=torch.Tensor([step]),
Y=torch.Tensor([line]),
win=win_name,
name='%s' % name
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.