# Simulate
from dstapi import DstApi
import seaborn as sns
import matplotlib.pyplot as plt
= DstApi("LONS20")
lon = {'table': 'lons20',
params 'format': 'BULK',
'lang': 'da',
'variables': [{'code': 'ARBF', 'values': ['TOT']},
'code': 'SEKTOR', 'values': ['1046']},
{'code': 'AFLOEN', 'values': ['TIFA']},
{'code': 'LONGRP', 'values': ['LTOT']},
{'code': 'LØNMÅL', 'values': ['STAND']},
{'code': 'KØN', 'values': ['M', 'K']},
{'code': 'Tid', 'values': ['*']}]}
{
= lon.get_data(params=params)[["KØN", "TID", "INDHOLD"]] df
Notebook generating plot(s) for blog post on gender gap
Start by getting data on hourly wages by gender over time
In [8]:
Plot
In [3]:
import seaborn as sns
import matplotlib.pyplot as plt
= plt.subplots(figsize=(8, 5))
fig, ax
= "#E75480"
kvcolor = "#4682B4"
mdcolor
sns.lineplot(="TID", y="INDHOLD", hue="KØN", data=df,
x={"Kvinder": kvcolor, "Mænd": mdcolor},
palette=False, ax=ax
legend
)
"TID"].unique())
plt.xticks(df[
= df.loc[(df["KØN"] == "Kvinder") & (df["TID"] == df["TID"].max()), "INDHOLD"].values[0]
kvinder_val = df.loc[(df["KØN"] == "Mænd") & (df["TID"] == df["TID"].max()), "INDHOLD"].values[0]
maend_val = 100*(kvinder_val - maend_val)/(maend_val)
diff
plt.annotate(f"{diff:.0f}%",
=(df["TID"].max(), (kvinder_val + maend_val)/2),
xy=(df["TID"].max() + 0.1,
xytext+ maend_val)/2),
(kvinder_val
)
"TID"].max(), df["TID"].max()], [kvinder_val, maend_val], lw=0.5, ls='--', color='black')
plt.plot([df[
"")
plt.xlabel("")
plt.ylabel(
210, 330)
plt.ylim(
sns.despine() plt.show()