是否将matplotlib图转换为bokeh时间线图?

2024-09-30 06:16:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用bokeh库绘制时间线图

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()

我试图有效地使用博克的时间线图来可视化我的数据。在这个问题上,任何人都可以帮助我,或者任何建议都是欢迎的

亲切问候,, 谢谢


Tags: csvcsvfileimportdataas时间bokehplt
1条回答
网友
1楼 · 发布于 2024-09-30 06:16:52

要使用bokeh图而不是matplotlib,您必须组织数据。我不能帮你,因为我没有你的档案。下面是一个原型,可以将一些数据点绘制成圆圈,欢迎您使用。如果这不是你想要的,请查看bokehgallery,因为这里有一些很好的例子

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)

相关问题 更多 >

    热门问题