You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sledge/runtime/data/polt.py

52 lines
1.7 KiB

import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
def load_data(filename):
"""
Load data from a file.
Assumes that each line in the file is a float value.
"""
with open(filename, 'r') as file:
data = file.read().split()
data = [float(i) for i in data]
return data
def main():
# 加载数据
edf_data = load_data('edf_5k.txt')
llf_data = load_data('llf_5k.txt')
# 设置X轴的数据点
x_labels = [50, 60, 70, 80, 90, 100] # 确保数据与这些标签相匹配
font_properties = fm.FontProperties(family='Times New Roman', size=18)
plt.rcParams.update({'font.size': 18, 'font.family': 'Times New Roman'})
# 创建图形和绘制数据
plt.figure(figsize=(10, 6))
ax = plt.gca() # 获取当前的Axes对象ax
ax.set_facecolor('#f0f0f0') # 设置浅灰色背景
plt.plot(x_labels, edf_data, marker='s', linestyle='-', color='#C8503D', markersize=8, label='EDF')
plt.plot(x_labels, llf_data, marker='^', linestyle='-', color='#00008B', markersize=8, label='LLF')
# 添加标题、标签和图例
plt.title('5KB-1.2* Deadline', fontsize=20, fontproperties=font_properties)
plt.xlabel('Load (% of maximum RPS)', fontproperties=font_properties)
plt.ylabel('Deadline Miss Rate (%)', fontproperties=font_properties)
plt.legend(prop=font_properties)
# 设置X轴刻度
plt.xticks(range(50, 101, 10))
# 设置网格
plt.grid(True)
# 移除边框的四边刻度线
plt.tick_params(axis='both', which='both', length=0) # 移除刻度线
# 显示图形
plt.show()
if __name__ == "__main__":
main()