本人在作接口測試的過程當中,使用了 python+plotly 統計接口信息,以前一直用Violin圖表,今天就嘗試了一中新的圖表,distplot 圖表,其實就是整數的柱形圖,而後加上一個變化曲線。下面來分享一下代碼,供你們參考。(接口響應時間存在一個本地的文件中了。)html
#!/usr/bin/python # coding=utf-8 import plotly.plotly import plotly.figure_factory as fff import numpy as np class Distplots: def ___init__(self): print "distplots圖標生成!" def makeDistplot(self, data, group): fig = fff.create_distplot(data, group) plotly.offline.plot(fig, filename="3333.html") if __name__ == "__main__": x = np.random.randn(1000) * 10 y = np.random.randn(1000) * 10 + 50 z = np.random.randn(1000) * 10 + 100 data = [x, y, z] group = ["one", "two", "three"] xy = [] one = open("/Users/Vicky/Documents/workspace/fission/long.log", "r") for line in one.readlines(): time = float(line) if time > 1: continue # print time xy.append(time) xy = [x * 100 for x in xy] data1 = [xy] group1 = ["test1"] drive = Distplots() drive.makeDistplot(data1, group1)
下面是製做完成的效果圖:java