|
| 1 | +import json |
| 2 | +import bokeh.plotting |
| 3 | +import bokeh.embed |
| 4 | +import bokeh.resources |
| 5 | +import bokeh.models |
| 6 | + |
| 7 | +#bokeh.plotting.output_notebook() |
| 8 | +test = json.loads( open( 'motorlog.json' ).read() ) |
| 9 | + |
| 10 | +r = bokeh.resources.Resources() |
| 11 | + |
| 12 | +for k,d in test['data'].items(): |
| 13 | + print k |
| 14 | + x = [row[0] for row in d] |
| 15 | + y0 = [row[1][0] for row in d] |
| 16 | + y1 = [row[1][1] for row in d] |
| 17 | + y2 = [row[1][2] for row in d] |
| 18 | + |
| 19 | + p = bokeh.plotting.figure(height=300, width=800, title=k) |
| 20 | + |
| 21 | + p.y_range=bokeh.models.Range1d(-200,2000) |
| 22 | + p.extra_y_ranges = { 'foo': bokeh.models.Range1d(start=-200, end=2000), |
| 23 | + 'duty_cycle': bokeh.models.Range1d(start=-10, end=100) } |
| 24 | + #p.add_layout( bokeh.models.LinearAxis(y_range_name='position'), 'right') |
| 25 | + p.add_layout( bokeh.models.LinearAxis(y_range_name='duty_cycle'), 'right') |
| 26 | + |
| 27 | + p.line(x, y0, legend='speed', line_width=2, color='red', y_range_name='foo') |
| 28 | + p.line(x, y1, legend='position', line_width=2, color='blue', y_range_name='foo') |
| 29 | + p.line(x, y2, legend='duty_cycle', line_width=2, color= 'green', y_range_name='duty_cycle') |
| 30 | + |
| 31 | + o = open('{0}.html'.format(k), 'w') |
| 32 | + o.write( bokeh.embed.file_html(p, r, title='foo' ) ) |
| 33 | + |
0 commit comments