Nagmat
Nagmat

Reputation: 390

Convert matplotlib graph to bokeh timeline graph?

I am trying to plot a timeline graph using bokeh library.

The image is the result of python code below

import matplotlib.pyplot as plt
import csv

with open('syscall.csv','r') as csvfile :
    rows = list(csv.reader(csvfile, delimiter=','))[1:]
    #rows.sort(key = lambda x: int(x[7])) 
    for row in rows:
        print(row[6])
        alfa=0.8
        renk = 'g'
        start, end, data = int(row[6]), int(row[14]), int(row[5])
        x = [start, end]
        y = [data, data]
        plt.plot(x, y, label=row[0], marker='o', color = renk)
plt.xlabel('time(milliseconds)')
plt.ylabel('Amount of Data(bytes)')
plt.title('VFS and EXT4 layer READ/WRITE graph')
plt.legend(['VR = Red, ER=black, VW=blue, EW=green, vr=%d, er=%d, vw=%d,ew=%d'%(vrc,erc,vwc,ewc)],loc='lower left')
plt.grid(True)
plt.savefig('test.png')
plt.show()

I am trying to use timeline graph of bokeh effectively in order to visualize my data. Can anyone help me regarding this issue or any advice is welcome.

Kind regards, Thanks

Upvotes: 0

Views: 671

Answers (1)

mosc9575
mosc9575

Reputation: 6347

Well, to use a bokeh plot instead of matplotlib you have to organize your data. I can not do it for you, because I don't have your file. Below is a prototype to plot some data points as circles you are welcome to use. If it is not what you wanted, please check out the bokeh gallery, because there are some goog examples.

from bokeh.plotting import output_notebook, figure, output_notebook, show
from bokeh.models import ColumnDataSource

output_notebook()

data = ColumnDataSource({'x':[1,2,3], 
                         'y':[10,30,20],
                         'color':['green', 'red', 'yellow']
                       })

p = figure(title='VFS and EXT4 layer READ/WRITE graph',
           x_axis_label = 'time(milliseconds)',
           y_axis_label = 'Amount of Data(bytes)',
          )

p.circle(x='x', y='y', color='color', source=data, legend_label='data')

show(p)

Upvotes: 1

Related Questions