import matplotlib.pyplot as plt
limits = (
(10, 9275),
(15, 37650),
(25, 91150),
(28, 190150),
(33, 413350),
(35, 415050),
(39.6, 500000)
)
def calc_tax(income):
tax = 0.0
taxed_to = 0.0
for i in range(len(limits)):
pct = limits[i][0] / 100.0
limit = limits[i][1]
if limit > income:
tax += pct * (income - taxed_to)
break
else:
tax += pct * (limit - taxed_to)
taxed_to = limit
return tax
income = range(1, 300000, 100)
tax = [calc_tax(x) for x in income]
effective_rate = [tax[i] / income[i] * 100.0 for i in range(0, len(tax))]
plt.plot(income,tax)
plt.title('Tax per income.')
plt.show()
plt.plot(income, effective_rate)
plt.title('Effective tax rate per income.')
plt.ylim([0, effective_rate[-1] + 5.0])
plt.show()