-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot.py
More file actions
100 lines (79 loc) · 3.71 KB
/
plot.py
File metadata and controls
100 lines (79 loc) · 3.71 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sys
import matplotlib
from matplotlib.ticker import FormatStrFormatter
matplotlib.rcParams['font.family'] = 'Times New Roman'
matplotlib.rcParams['pdf.fonttype'] = '42'
matplotlib.rcParams['ps.fonttype'] = '42'
plt.rc('text', usetex=True)
ticks_font_size = 25
files = [
'./results_rq1_csv/hdd_ddmin_c.csv',
'./results_rq1_csv/perses_ddmin_c.csv',
'./results_rq1_csv/hdd_ddmin_xml.csv',
'./results_rq1_csv/perses_ddmin_xml.csv',
]
def c_spearman_by_benchmark():
dfs = []
for i in range(0, 2):
file = files[i]
df = pd.read_csv(file)
df = df[~df['Benchmark'].str.startswith('rust')]
# df = df['spearman_corr']
average_spearman_corr = df.groupby('Benchmark')['spearman_corr'].mean().reset_index()
print(average_spearman_corr)
dfs.append(average_spearman_corr['spearman_corr'])
combined_data = pd.concat(dfs, axis=1)
combined_data.columns = [r'HDD\textsubscript{d}', r'Perses\textsubscript{d}']
plt.figure(figsize=(6, 4))
box_plot = sns.boxplot(data=combined_data, width=0.4, boxprops=dict(facecolor='none'), showfliers=False)
sns.stripplot(data=combined_data, palette='Set2', size=6, alpha=0.9, jitter=True)
mean_values = combined_data.mean()
std_values = combined_data.std()
# Add a red dashed line at y=1.0
plt.axhline(y=0.0, linestyle='--', color='gray', linewidth=2.0)
print(plt.gca().get_ylim())
plt.ylim(bottom=-0.80, top=0.5)
plt.xticks(fontsize=ticks_font_size)
plt.yticks(fontsize=ticks_font_size)
plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
# show mean and std on top of the box plot
for i in range(len(mean_values)):
plt.text(i, 0.39, f'$\mu$ = {mean_values[i]:.2f}', ha='center', va='bottom', fontsize=18, color='black')
plt.text(i, 0.30, f'$\sigma$ = {std_values[i]:.2f}', ha='center', va='bottom', fontsize=18, color='black')
plt.show()
# plt.savefig('correlation-ddmin-c-spearman_by_benchmark.pdf', format='pdf', bbox_inches='tight', dpi=300)
def xml_spearman_by_benchmark():
dfs = []
for i in range(2, 4):
file = files[i]
df = pd.read_csv(file)
df = df[~df['Benchmark'].str.startswith('rust')]
average_spearman_corr = df.groupby('Benchmark')['spearman_corr'].mean().reset_index()
print(average_spearman_corr)
dfs.append(average_spearman_corr['spearman_corr'])
combined_data = pd.concat(dfs, axis=1)
combined_data.columns = [r'HDD\textsubscript{d}', r'Perses\textsubscript{d}']
plt.figure(figsize=(6, 4))
box_plot = sns.boxplot(data=combined_data, width=0.4, boxprops=dict(facecolor='none'), showfliers=False)
sns.stripplot(data=combined_data, palette='Set2', size=6, alpha=0.9, jitter=True)
mean_values = combined_data.mean()
std_values = combined_data.std()
# Add a red dashed line at y=1.0
plt.axhline(y=0.0, linestyle='--', color='gray', linewidth=2.0)
print(plt.gca().get_ylim())
plt.ylim(bottom=-1, top=1)
plt.xticks(fontsize=ticks_font_size)
plt.yticks(fontsize=ticks_font_size)
plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
# show mean and std on top of the box plot
for i in range(len(mean_values)):
plt.text(i, 0.50, f'$\mu$ = {mean_values[i]:.2f}', ha='center', va='bottom', fontsize=18, color='black')
plt.text(i, 0.36, f'$\sigma$ = {std_values[i]:.2f}', ha='center', va='bottom', fontsize=18, color='black')
plt.show()
# plt.savefig('correlation-ddmin-xml-spearman_by_benchmark.pdf', format='pdf', bbox_inches='tight', dpi=300)
if __name__ == '__main__':
c_spearman_by_benchmark()
xml_spearman_by_benchmark()