# Python 3.9.2
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from est_tarife import D_Steuersatz, Grenzsteuersatz
import locale
# Umstellung auf Deutsch:
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
# generelle Schrift
font = {'family': 'sans serif',
'weight': 'normal',
'style': 'normal',
'size': '12'}
mpl.rc('font', **font)
# x/y-Achsen
mpl.rc('xtick', labelsize=16)
mpl.rc('ytick', labelsize=16)
def plot_splittingtarif(jahr):
samples = 1000
xmin = 0; xmax = 150000
ymin = 0; ymax = 50
X = np.arange(xmin, xmax, xmax/samples)
fig = plt.figure(figsize=(16.0, 9.0), dpi=75)
ax = fig.add_subplot(111) #ZeilenSpaltenPos
ax.set_title(f'Grund- und Splittingtarif {jahr}', horizontalalignment='center', y=1.03, fontsize=24, fontweight='bold')
axr = ax.twinx()
plt.suptitle("Einkommensteuer Deutschland")
ax.set_xlabel('Jährlich zu versteuerndes Einkommen in Euro', fontsize=18, fontweight='bold', labelpad=10)
ax.plot(X, [100*D_Steuersatz(x, 0, jahr) for x in X], c='b', label='Grundtarif')
ax.plot(X, [100*D_Steuersatz(x, 1, jahr) for x in X], c='r', label='Splittingtarif')
ax.plot(X, [100*Grenzsteuersatz(x, 0, jahr) for x in X], c='b', ls=':')
ax.plot(X, [100*Grenzsteuersatz(x, 1, jahr) for x in X], c='r', ls=':')
set_texte(plt, jahr)
ax.legend(loc='upper left', fontsize=16, borderpad=0.8, labelspacing=1)
ax.grid(b=True, which='major', color='gray', lw=0.4, linestyle='--', alpha=0.7)
ax.grid(b=True, which='minor', color='gray', lw=0.2, linestyle='--', alpha=0.5)
ax.minorticks_on()
#ax.grid(lw=0.5, ls=':')
set_xticks_and_xticklabels(ax, xmin, xmax)
set_yticks_and_yticklabels(ax, axr, ymax)
ax.text(-6000,-12, f'CC BY-SA 4.0, Udo Brechtel, {jahr}', fontsize=8, fontweight='normal', color='black')
plt.tight_layout()
plt.savefig(f'bilder/ESt D Splittingtarif {jahr} zvE bis {xmax}.svg')
#plt.show()
def set_texte(plt, jahr):
plt.figtext(0.01, 0.91, "Grenzsteuersatz (gestrichelte Linie)\n∅-Steuersatz (durchgezogene Linie)", fontsize=14, fontweight='bold')
zve_0 = 30000
zve_1 = 2 * zve_0
s_0 = 100 * D_Steuersatz(zve_0, 0, jahr)
s_1 = 100 * D_Steuersatz(zve_1, 1, jahr)
ax = plt.gca()
ax.axhline(s_0, color='black', lw=0.7)
ax.axvline(zve_0, ymax=s_0/100+0.18, color='black', lw=0.7)
ax.axvline(zve_1, ymax=s_1/100+0.18, color='black', lw=0.7)
zve_0_text = locale.format_string('%d €', zve_0, True)
zve_1_text = locale.format_string('%d €', zve_1, True)
s_text = locale.format_string('%.1f %%', s_0, True)
print(zve_0_text, zve_1_text, s_text)
ax.text(zve_1+2000, s_1-1.5,
f"Beispiel:\nDas zvE = {zve_1_text} eines Ehepaares wird mit insgesamt {s_text} besteuert.\nFür das zvE = {zve_0_text} einer Einzelperson gilt der gleiche ∅-Steuersatz.", fontsize=14, va='top',
bbox={'facecolor':'white', 'edgecolor':"gray", 'boxstyle':'round,pad=0.3'})
def set_xticks_and_xticklabels(ax, xmin, xmax):
ax.tick_params(axis='both', pad=10)
xticks = [x for x in range(xmin, xmax+1, 10000)]
xticklabels = [locale.format_string('%d', x, True) for x in xticks]
ax.set_xticks(xticks)
ax.set_xticklabels(xticklabels, rotation=90)
ax.set_xlim(xticks[0], xticks[-1])
def set_yticks_and_yticklabels(ax, axr, y_max):
ax.tick_params(axis='y', pad=10)
axr.tick_params(axis='y', pad=10)
yticks = [x for x in range(0, y_max+1, 5)]
yticklabels = [locale.format_string('%d %%', x, True) for x in yticks]
ax.set_yticks(yticks)
axr.set_yticks(yticks)
ax.set_yticklabels(yticklabels)
axr.set_yticklabels(yticklabels)
ax.set_ylim(yticks[0], yticks[-1])
# RUN
jahr = 2023
plot_splittingtarif(jahr)
#EOF