本人在做接口测试的过程中,使用了 python+plotly 统计接口信息,之前一直用Violin图表,今天就尝试了一中新的图表,distplot 图表,其实就是整数的柱形图,然后加上一个变化曲线。下面来分享一下代码,供大家参考。(接口响应时间存在一个本地的文件中了。)
1#!/usr/bin/python
2# coding=utf-8
3
4import plotly.plotly
5import plotly.figure_factory as fff
6import numpy as np
7
8
9class Distplots:
10 def ___init__(self):
11 print "distplots图标生成!"
12
13 def makeDistplot(self, data, group):
14 fig = fff.create_distplot(data, group)
15 plotly.offline.plot(fig, filename="3333.html")
16
17
18if __name__ == "__main__":
19 x = np.random.randn(1000) * 10
20 y = np.random.randn(1000) * 10 + 50
21 z = np.random.randn(1000) * 10 + 100
22 data = [x, y, z]
23 group = ["one", "two", "three"]
24 xy = []
25 one = open("/Users/Vicky/Documents/workspace/fission/long.log", "r")
26 for line in one.readlines():
27 time = float(line)
28 if time > 1:
29 continue
30 # print time
31 xy.append(time)
32 xy = [x * 100 for x in xy]
33 data1 = [xy]
34 group1 = ["test1"]
35 drive = Distplots()
36 drive.makeDistplot(data1, group1)
下面是制作完成的效果图:

原文作者:FunTester;如有侵权,请联系管理员删除。