@@ -698,27 +698,12 @@ ginis.head(n=5)
698
698
699
699
Let's plot the Gini coefficients for net wealth, labor income and total income.
700
700
701
- Looking at each data series we see an outlier in Gini coefficient computed for 1965 for `labour income`.
702
-
703
- We will smooth our data and take an average of the data either side of it for the time being.
704
-
705
- ```{code-cell} ipython3
706
- ginis["l_income"][1965] = (ginis["l_income"][1962] + ginis["l_income"][1968]) / 2
707
- ax = ginis["l_income"].plot()
708
- ax.set_ylabel("Gini coefficient")
709
- plt.show()
710
- ```
711
-
712
- Now we can focus on US net wealth
713
-
714
701
```{code-cell} ipython3
715
702
---
716
703
mystnb:
717
704
figure:
718
705
caption: Gini coefficients of US net wealth
719
706
name: gini_wealth_us
720
- image:
721
- alt: gini_wealth_us
722
707
---
723
708
fig, ax = plt.subplots()
724
709
ax.plot(years, ginis["n_wealth"], marker='o')
@@ -727,16 +712,22 @@ ax.set_ylabel("Gini coefficient")
727
712
plt.show()
728
713
```
729
714
730
- and look at US income for both labour and a total income (excl. capital gains)
715
+ Looking at each data series we see an outlier in Gini coefficient computed for 1965 for `labour income`.
716
+
717
+ We will smooth our data and take an average of the data either side of it for the time being.
718
+
719
+ ```{code-cell} ipython3
720
+ ginis["l_income"][1965] = (ginis["l_income"][1962] + ginis["l_income"][1968]) / 2
721
+ ```
722
+
723
+ Now looking at US income for both labour and a total income.
731
724
732
725
```{code-cell} ipython3
733
726
---
734
727
mystnb:
735
728
figure:
736
729
caption: Gini coefficients of US income
737
730
name: gini_income_us
738
- image:
739
- alt: gini_income_us
740
731
---
741
732
fig, ax = plt.subplots()
742
733
ax.plot(years, ginis["l_income"], marker='o', label="labor income")
@@ -750,6 +741,12 @@ plt.show()
750
741
Now we can compare net wealth and labour income.
751
742
752
743
```{code-cell} ipython3
744
+ ---
745
+ mystnb:
746
+ figure:
747
+ caption: Gini coefficients of US net wealth and labour income
748
+ name: gini_wealth_us
749
+ ---
753
750
fig, ax = plt.subplots()
754
751
ax.plot(years, ginis["n_wealth"], marker='o', label="net wealth")
755
752
ax.plot(years, ginis["l_income"], marker='o', label="labour income")
@@ -791,11 +788,14 @@ data[['NOR']].dropna().head(n=5)
791
788
792
789
The data for Norway in this dataset goes back to 1979 but there are gaps in the time series and matplotlib is not showing those data points.
793
790
794
- We can use `dataframe .ffill()` to copy and bring forward the last known value in a series to fill in these gaps
791
+ We can use the ` .ffill()` method to copy and bring forward the last known value in a series to fill in these gaps
795
792
796
793
```{code-cell} ipython3
797
794
data['NOR'] = data['NOR'].ffill()
798
- data[['USA','GBR', 'NOR']].plot(ylabel='gini coefficient')
795
+ ax = data[['USA','GBR', 'NOR']].plot()
796
+ ax.set_xlabel('year')
797
+ ax.set_ylabel('Gini coefficient')
798
+ plt.show()
799
799
```
800
800
801
801
From this plot we can observe that the USA has a higher Gini coefficient (i.e. higher income inequality) when compared to the UK and Norway.
@@ -854,6 +854,7 @@ labels = [1979, 1986, 1991, 1995, 2000, 2020, 2021, 2022] + list(range(min_year,
854
854
plot_data.year = plot_data.year.map(lambda x: x if x in labels else None)
855
855
```
856
856
857
+ (fig:plotly-gini-gdppc-years)=
857
858
```{code-cell} ipython3
858
859
fig = px.line(plot_data,
859
860
x = "gini",
@@ -867,6 +868,10 @@ fig.update_traces(textposition="bottom right")
867
868
fig.show()
868
869
```
869
870
871
+ ```{only} latex
872
+ This figure is built using `plotly` and is {ref}` available on the website <fig:plotly-gini-gdppc-years>`
873
+ ```
874
+
870
875
This plot shows that all three western economies gdp per capita has grown over time with some fluctuations
871
876
in the Gini coefficient. However the appears to be significant structural differences between Norway and the USA.
872
877
0 commit comments