Use symlog scale instead of log

This commit is contained in:
Benjamin Loison 2024-10-02 00:33:11 +02:00
parent ef3e8ef337
commit f090374caf
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -39,6 +39,8 @@ PRINT_TRANSACTIONS = False
totalMonthlyDebits = []
totalMonthlyCredits = []
totalMonthlyDifferences = []
totals = []
firstDatetime = None
lastDatetime = None
for folder in sorted(os.listdir()):
@ -66,6 +68,7 @@ for folder in sorted(os.listdir()):
currentAmount = initialAmount
print('Initial amount', initialAmount)
print()
totals += [initialAmount]
started = True
continue
else:
@ -82,6 +85,9 @@ for folder in sorted(os.listdir()):
print(f'Total monthly credit: {totalMonthlyCredit}')
totalMonthlyDebits += [totalMonthlyDebit]
totalMonthlyCredits += [totalMonthlyCredit]
totalMonthlyDifference = totalMonthlyCredit - totalMonthlyDebit
#print(totalMonthlyDifference)
totalMonthlyDifferences += [totalMonthlyDifference]
break
if firstLineOfPaymentRegex.match(line) is not None:
if date is not None and PRINT_TRANSACTIONS:
@ -108,21 +114,23 @@ def getMonthIndex(aDatetimeStr):
aDatetime = datetime.strptime(aDatetimeStr, '%Y%m%d.pdf')
return aDatetime.year * 12 + aDatetime.month
'''
print(firstDatetime)
print(lastDatetime)
exit(1)
'''
#print(getMonthIndex(firstDatetime))
#print(getMonthIndex(lastDatetime))
xTicks = range(getMonthIndex(firstDatetime), getMonthIndex(lastDatetime) + 1)
#print(len(xTicks))
#print(len(totalMonthlyDebits))
plt.bar(xTicks, totalMonthlyDebits, alpha = ALPHA, label = 'Debit')
plt.bar(xTicks, totalMonthlyCredits, alpha = ALPHA, label = 'Credit')
# sign does not seem respected for `totalMonthlyDifferences`.
#print(totalMonthlyDifferences)
#print(f'{min(totalMonthlyDifferences)}')
#print(f'{max(totalMonthlyDifferences)}')
totalMonthlyAmountAndLabel = (
#(totalMonthlyDebits, 'Debit'),
#(totalMonthlyCredits, 'Credit'),
(totalMonthlyDifferences, 'Difference'),
(totals, 'Total'),
)
for totalMonthlyAmount, totalMonthlyLabel in totalMonthlyAmountAndLabel:
plt.bar(xTicks, totalMonthlyAmount, alpha = ALPHA, label = totalMonthlyLabel)
plt.legend()
plt.yscale('log')
# Hides negative
#plt.yscale('symlog')
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,}'))
def getMonthName(monthIndex):