官方文档:https://matplotlib.org/stable/gallery/index.html
# coding=UTF-8
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# import sys
# reload(sys)
# sys.setdefaultencoding('utf-8')
labels = ['5ms','10ms','50ms','100ms','500ms','1000ms','10000ms','20000ms','30000ms','40000ms','50000ms']
dis = [8.36, 8.67, 8.06, 12.96, 22.26, 27.77, 100.98, 152.21, 197.46, 236.11, 299.01] # cbf
# women_means = [25, 32, 34, 20, 25]
x = np.arange(len(labels)) # the label locations
width = 0.6 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(x, dis, width, color='#D55E00', edgecolor='#D55E00',log=True, align='center') # for time
# rects2 = ax.bar(x + width/2, women_means, width, label='分布式') #可以设置两个柱子的比价,具体看官方文档里的example
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('time (s)')
plt.ylim(0,1000)
ax.set_xlabel('window size')
ax.set_title('Recovery Time on Distributed (cbf)')
ax.set_xticks(x) #设置坐标轴标签上的值,显示什么字,以及字是否倾斜
ax.set_xticklabels(labels)
# ax.legend() #设置右上角图例
def autolabel(rects):
"""Attach a text label above each bar in *rects*, displaying its height."""
for rect in rects:
height = rect.get_height()
ax.annotate('{}'.format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points vertical offset
textcoords="offset points",
ha='center', va='bottom')
autolabel(rects1)
# autolabel(rects2)
fig.tight_layout()
plt.show()
本文通过Matplotlib库创建了一张图表,展示了不同窗口大小下分布式环境中的RecoveryTime(恢复时间),重点在于8.36ms到50,000ms的时间范围。数据可视化有助于理解各延迟对性能的影响。
659

被折叠的 条评论
为什么被折叠?



