PolicyEngine / policyengine-uk

The UK's only open-source static tax-benefit microsimulation model.
https://policyengine.github.io/policyengine-uk/
GNU Affero General Public License v3.0
27 stars 27 forks source link

Add documentation page for Income Tax #759

Closed chelsea128 closed 9 months ago

chelsea128 commented 11 months ago

Thanks for contributing to OpenFisca! Please remove this line, as well as, for each line below, the cases which are not relevant to your contribution :)

These changes (remove lines which are not relevant to your contribution):

nikhilwoodruff commented 10 months ago
from policyengine_uk import Simulation

simulation = Simulation(
    situation=dict(
            people=dict(
            person=dict(
                age=30,
                dividend_income=10_000,
            )
        ),
        axes=[[
            dict(
                name="employment_income",
                min=0,
                max=200_000,
                count=1_000,
            )
        ]]
    ),
)

import plotly.express as px
import pandas as pd
from policyengine_core.charts import format_fig

df = pd.DataFrame({
    "Employment income": simulation.calculate("employment_income"),
    "Income tax": simulation.calculate("income_tax"),
    "Dividend income tax": simulation.calculate("dividend_income_tax"),
})

fig = px.line(
    df,
    x="Employment income",
    y=["Income tax", "Dividend income tax"],
    title="Income tax vs employment income",
    labels={
        "value": "Income tax (£)",
        "variable": "Tax type",
    },
)

format_fig(fig)