Skip to content

Commit 7a9dbf6

Browse files
committed
update figures with mystnb figure settings
1 parent de9b5d2 commit 7a9dbf6

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

lectures/inequality.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ Using `pandas` we can take a quick look across all countries and all years in th
567567
By leaving off the `"USA"` this function returns all Gini data that is available.
568568

569569
```{code-cell} ipython3
570+
---
571+
mystnb:
572+
figure:
573+
caption: Histogram of Gini coefficients
574+
name: gini_histogram
575+
---
570576
# Fetch gini data for all countries
571577
gini_all = wb.data.DataFrame("SI.POV.GINI")
572578
gini_all.columns = gini_all.columns.map(lambda x: int(x.replace('YR',''))) # remove 'YR' in index and convert to int
@@ -588,6 +594,12 @@ We can see that across 50 years of data and all countries (including low and hig
588594
Let us zoom on the US data so we can more clearly observe trends.
589595

590596
```{code-cell} ipython3
597+
---
598+
mystnb:
599+
figure:
600+
caption: Gini coefficients (USA)
601+
name: gini_usa_trend
602+
---
591603
fig, ax = plt.subplots()
592604
ax = data_usa.plot(ax=ax)
593605
ax.set_ylim(data_usa.min()-1, data_usa.max()+1)
@@ -740,6 +752,12 @@ There are 167 countries represented in this dataset.
740752
Let us compare three western economies: USA, United Kingdom, and Norway
741753

742754
```{code-cell} ipython3
755+
---
756+
mystnb:
757+
figure:
758+
caption: Gini coefficients (USA, United Kingdom, and Norway)
759+
name: gini_usa_gbr_nor1
760+
---
743761
ax = data[['USA','GBR', 'NOR']].plot()
744762
ax.set_xlabel('year')
745763
ax.set_ylabel('Gini coefficient')
@@ -758,6 +776,12 @@ The data for Norway in this dataset goes back to 1979 but there are gaps in the
758776
We can use the `.ffill()` method to copy and bring forward the last known value in a series to fill in these gaps
759777

760778
```{code-cell} ipython3
779+
---
780+
mystnb:
781+
figure:
782+
caption: Gini coefficients (USA, United Kingdom, and Norway)
783+
name: gini_usa_gbr_nor2
784+
---
761785
data['NOR'] = data['NOR'].ffill()
762786
ax = data[['USA','GBR', 'NOR']].plot()
763787
ax.set_xlabel('year')
@@ -820,6 +844,12 @@ plot_data.year = plot_data.year.map(lambda x: x if x in labels else None)
820844
(fig:plotly-gini-gdppc-years)=
821845

822846
```{code-cell} ipython3
847+
---
848+
mystnb:
849+
figure:
850+
caption: Gini coefficients and GDP per capita (USA, United Kingdom, and Norway)
851+
name: gini_gdppc_usa_gbr_nor1
852+
---
823853
fig = px.line(plot_data,
824854
x = "gini",
825855
y = "gdppc",
@@ -928,8 +958,6 @@ mystnb:
928958
figure:
929959
caption: US top shares
930960
name: top_shares_us
931-
image:
932-
alt: top_shares_us
933961
---
934962
fig, ax = plt.subplots()
935963
ax.plot(years, df_topshares["topshare_l_income"],

0 commit comments

Comments
 (0)