#----------------
# python3
#----------------
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.ticker import FormatStrFormatter
from tarife import ESt32a
#Konstanten
Fliesskommaformat = FormatStrFormatter('%1.3f')
Prozentformat = FormatStrFormatter('%g %%')
Euroformat = FormatStrFormatter('%g €')
xmax, ymax = 90000, 47
p = 0.02 #Inflationsrate = zvE-Steigerungsrate
q = 1 + p
nFrames = 42 #gerade Zahl; Animation Anzahl frames
x0 = 30000
y0 = 100*ESt32a(x0, False, 0, True, 2, 1) #qi = 1
fig = plt.figure(figsize=(8,6), dpi=150)
ax = fig.subplots()
fig.suptitle('Kalte Progression (allgemeines Beispiel)', fontsize=18, fontweight='bold')
ax.set_xlim(0, xmax)
ax.set_ylim(0, ymax)
X = np.linspace(0, xmax, 500)
Y1o, Y2o = [], []
for x1 in X:
y1 = 100*ESt32a(x1, False, 0, True, 1, 1.0)
Y1o.append(y1)
y2 = 100*ESt32a(x1, False, 0, True, 2, 1.0)
Y2o.append(y2)
Linie1, = ax.plot(X, Y1o, 'r:', label='Grenzsteuersatz')
Linie2, = ax.plot(X, Y2o, 'r-', label='∅-Steuersatz')
Punkt, = ax.plot([x0], [y0], 'bo', markersize=8, label=None)
Pfeil, = ax.plot([],[], 'b<', markersize=8)
Pfeil1, = ax.plot([],[], 'b-', lw=0.8)
Pfeil2, = ax.plot([],[], 'b-', lw=0.5)
Titel1 = ax.text(xmax/2, ymax+1, '??? Kompensation', fontsize=24, fontweight='bold', ha='center')
Text1 = ax.text(5000,42, '', color='b', fontsize=18, fontweight='bold', backgroundcolor='white')
Text2 = ax.text(46000,8, '...index', color='blue', fontsize=13, fontweight='bold', backgroundcolor='white',
bbox=dict(facecolor='white', edgecolor='black', pad=0.4, boxstyle='round'))
Text0 = ax.text(xmax/2,ymax/2,'Kalte Progression\nohne Kompensation', color='black', fontsize=24, fontweight='bold', backgroundcolor='white', ha='center',
bbox=dict(facecolor=(0.98,0.98,0.82), edgecolor='r', boxstyle='round'))
textCC = ax.text(-11000, -7, 'CC BY-SA 4.0, Udo Brechtel', fontsize=8, fontweight='normal', ha='left')
ax.legend(loc='lower right')
ax.grid()
ax.yaxis.set_major_formatter(Prozentformat)
ax.set_xlabel('Jährlich zu versteuerndes Einkommen in Euro', fontsize=12, fontweight='bold', labelpad=10)
ax.set_ylabel('Grenz-/∅-Steuersatz', fontsize=12, fontweight='bold', labelpad=15)
fig.tight_layout()
fig.subplots_adjust(top=0.86)
def set_Punkt(xP, yP):
Punkt.set_data(xP, yP)
Pfeil.set_data(1000, yP)
Pfeil1.set_data([xP,xP],[0,ymax])
Pfeil2.set_data([xP,0], [yP,yP])
def set_Text1(i):
if i == 0:
Text1.set_text('Jahr x ')
else:
Text1.set_text('Jahr x + ' + str(i))
def set_Text2(xP,yP, qi):
indexPreis = round(100*qi, 1) #Lohnindex = Preisindex !!!!!!!!!!!!
indexLohn = round(100*qi, 1) #Lohnindex = Preisindex !!!!!!!!!!!!
indexLohnNachSteuer = round(100*xP*(1-yP/100)/(x0*(1 - y0/100)), 1)
verlustReal = 100 * (indexLohnNachSteuer / indexLohn -1)
text1a = '{:.1f}'.format(indexPreis).replace('.', ',') + ' = Preisindex (Jahr x ≙ 100)'
text1b = '{:.1f}'.format(indexLohn).replace('.', ',') + ' = Einkommensindex vor Steuer'
text1c = '{:.1f}'.format(indexLohnNachSteuer).replace('.', ',') + ' = Lohnindex nach Steuer'
text1d = '{:.1f}'.format(verlustReal).replace('.', ',') + ' % = Reallohnverlust'
Text2.set_text(text1a+'\n'+text1c+'\n'+text1d)
def animate(i):
#print(i)
iwechsel = int(nFrames / 2)
if i < iwechsel:
return animation1(i)
else:
##Titel1.set_text('mit Kompensation')
return animation2(i - iwechsel)
def animation1(i):
#ohne Kompensation
Titel1.set_text('ohne Kompensation')
if i==0:
Text0.set_text('Kalte Progression\nohne Kompensation')
Text0.set_visible(True)
elif i==1:
Text0.set_visible(False)
Linie1.set_data(X, Y1o)
Linie2.set_data(X, Y2o)
qi = q**i
xP = round(x0 * qi, 0)
yP = round(100*ESt32a(xP, False, 0, True, 2, 1), 2)
set_Punkt(xP, yP)
set_Text1(i)
set_Text2(xP,yP, qi)
return (Linie1, Linie2, Punkt, Titel1, Text1, Text2, Pfeil, Pfeil1, Pfeil2, Text0)
def animation2(i):
#mit Kompensation
Titel1.set_text('mit Kompensation')
if i==0:
Text0.set_text('Kalte Progression\nmit Kompensation')
Text0.set_visible(True)
elif i==1:
Text0.set_visible(False)
qi = q**i
Y1m, Y2m = [], []
for x in X:
y = 100*ESt32a(x, False, 0, True, 1, qi)
Y1m.append(y)
y = 100*ESt32a(x, False, 0, True, 2, qi)
Y2m.append(y)
Linie1.set_data(X, Y1m)
Linie2.set_data(X, Y2m)
xP = round(x0 * qi, 0)
yP = round(100*ESt32a(xP, False, 0, True, 2, qi), 2)
set_Punkt(xP, yP)
set_Text1(i)
set_Text2(xP,yP, qi)
myAnimation = animation.FuncAnimation(fig, animate, frames=nFrames, \
interval=500, repeat=True, repeat_delay=2000) #blit=True nicht benutzen
myAnimation.save('kalte_progression_ohne_mit_kompensation.gif', writer='imagemagick')
plt.show()