-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-rq1.py
More file actions
57 lines (46 loc) · 1.61 KB
/
Copy pathplot-rq1.py
File metadata and controls
57 lines (46 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# 读取CSV文件
df = pd.read_csv('rq1_data.csv')
# 数据集和算法
labels = ['TPC-C', 'Voter', 'YCSB', 'Twitter', 'Wikipedia']
algorithms = ['TDE', 'EGC', 'DCL']
# 设置柱状图的宽度
bar_width = 0.2
index = np.arange(len(labels))
# 获取所有唯一的指标
metrics = df['Metric'].unique()
# 绘制图表
for metric in metrics:
# 创建新的图形
plt.figure(figsize=(6, 4))
# 获取当前指标的数据
metric_data = df[df['Metric'] == metric]
# 绘制柱状图
for j, algorithm in enumerate(algorithms):
values = metric_data[algorithm].values
plt.bar(index + j * bar_width, values, bar_width,
label=algorithm, alpha=1.0)
if metric != 'FE Time':
plt.axhline(y=50, color='gray', linestyle='--', linewidth=2)
# 为FE Time设置对数坐标轴
if metric == 'FE Time':
plt.yscale('log')
# 添加标签
plt.xlabel('Dataset', fontsize=16)
if metric == 'FE Time':
plt.ylabel(f'{metric} (log scale, s)', fontsize=16)
# FE Time 图例放在中间
plt.legend(fontsize=14, loc='center')
else:
plt.ylabel(metric, fontsize=16)
# 其他图表的图例保持在右下角
plt.legend(fontsize=14, loc='lower right')
plt.xticks(index + bar_width / 2, labels, fontsize=14, rotation=15)
plt.tick_params(axis='y', labelsize=14)
# 调整布局
plt.tight_layout()
# 保存为pdf格式
plt.savefig(f'fig/RQ1-{metric}.pdf', format='pdf', dpi=300, transparent=False)
plt.close()