def dyplot(data, **kwargs):
""" Plot data as line chart with dygraph
Params:
data: either a 2-d numpy array or a list of lists.
win: pane id
labels: list of series names, first series is always the X-axis
see http://dygraphs.com/options.html for other supported options
"""
win = kwargs.get('win') or uid()
dataset = {}
if type(data).__module__ == np.__name__:
dataset = data.tolist()
else:
dataset = data
# clone kwargs into options
options = dict(kwargs)
options['file'] = dataset
if options.get('labels'):
options['xlabel'] = options['labels'][0]
# Don't pass our options to dygraphs.
options.pop('win', None)
return pane('plot', kwargs.get('win'), kwargs.get('title'), content=options)
评论列表
文章目录