mirror of
https://github.com/Xevion/unbelievaselfbot.git
synced 2025-12-14 14:13:34 -06:00
plot task data with line plot and stacked plot
This commit is contained in:
41
stat_analysis.py
Normal file
41
stat_analysis.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import re
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
i = 0
|
||||
with open('raw_ash.txt', 'r', encoding='utf-8') as file:
|
||||
working = {'work': 0, 'slut': 0, 'crime': 0, 'total': 0}
|
||||
changes = {'work': [0], 'slut': [0], 'crime': [0], 'total': [0]}
|
||||
matches = re.finditer(
|
||||
r'\[[0-9-:, ]+\] \[\w+\] \[\w+\] Executing \$(work|crime|slut) task.\n\[[0-9-:, ]+\] \[\w+\] \[\w+\] (Gained|Lost) \$(\d+)',
|
||||
file.read())
|
||||
|
||||
for match in matches:
|
||||
task, sign, change = match.group(1), match.group(2) == 'Lost', int(match.group(3))
|
||||
if sign:
|
||||
change *= -1
|
||||
print(task, sign, change)
|
||||
|
||||
working[task] += int(change)
|
||||
working['total'] += int(change)
|
||||
for key in changes.keys():
|
||||
changes[key].append(working[key])
|
||||
# changes[key].append(max(0, working[key]))
|
||||
|
||||
print('Finished processing datafile.')
|
||||
|
||||
for k, v in working.items():
|
||||
print(f'{k} earned {v}.')
|
||||
print(f'{sum(working.values())} earned total.')
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
xaxis = list(range(len(changes['work'])))
|
||||
for k, v in changes.items():
|
||||
ax.plot(xaxis, v, label=k)
|
||||
# ax.stackplot(, changes.values(), labels=changes.keys())
|
||||
ax.legend(loc='upper left')
|
||||
ax.set_title('Earnings by Task over time')
|
||||
ax.set_xlabel('Tasks')
|
||||
ax.set_ylabel('Earnings ($)')
|
||||
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user