-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoken_plot.py
40 lines (28 loc) · 1 KB
/
token_plot.py
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
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
data = [('ReAct', 43), ('Self-consistency', 212), ('Debate (ours)', 95)]
# Extracting labels and values
labels, values = zip(*data)
# Converting values from thousands to actual values
values = [v * 1000 for v in values]
custom_color = '#0059ff'
# Creating the bar graph
plt.bar(labels, values, color=custom_color)
# Adding labels and title
plt.xlabel('Agents', fontsize=14, labelpad=10)
plt.ylabel('Tokens', fontsize=14)
# plt.title('Average Tokens Used per Task', fontsize=16)
# Function to format y-axis labels with 'k'
def format_func(value, tick_number):
if value == 0:
return "0"
return f'{int(value/1000)}k'
# Apply the custom formatter to the y-axis ticks
plt.gca().yaxis.set_major_formatter(FuncFormatter(format_func))
plt.yticks(fontsize=12)
plt.xticks(fontsize=12)
# Adjusting layout to prevent y-axis label cutoff
plt.tight_layout()
plt.savefig('agent_tokens.png', dpi=1000)
# Displaying the bar graph
plt.show()