@@ -145,7 +145,7 @@ households own just over 40\% of total wealth.
145145---
146146mystnb:
147147 figure:
148- caption: Lorenz Curves For Simulated Data
148+ caption: Lorenz curve of simulated data
149149 name: lorenz_simulated
150150---
151151n = 2000
@@ -165,8 +165,6 @@ ax.hlines([0.43], [0], [0.8], alpha=0.5, colors='k', ls='--')
165165ax.set_ylim((0, 1))
166166ax.set_xlim((0, 1))
167167
168- plt.title("Lorenz curve of simulated data") # TODO shift to the render
169-
170168plt.show()
171169```
172170
@@ -242,10 +240,10 @@ US in 2016.
242240---
243241mystnb:
244242 figure:
245- caption: "US Lorenz Curves \n "
243+ caption: "2016 US Lorenz curves "
246244 name: lorenz_us
247245 image:
248- alt: lorenz_real
246+ alt: lorenz_us
249247 classes: shadow bg-primary
250248 width: 75%
251249---
@@ -256,8 +254,7 @@ ax.plot(f_vals_ti[-1], l_vals_ti[-1], label=f'total income')
256254ax.plot(f_vals_li[-1], l_vals_li[-1], label=f'labor income')
257255ax.plot(f_vals_nw[-1], f_vals_nw[-1], label=f'equality')
258256
259- ax.legend(fontsize=12)
260- plt.title("Lorenz curves of US data in 2016")
257+ ax.legend(fontsize=12)
261258plt.show()
262259```
263260
@@ -311,7 +308,7 @@ The idea is that $G=0$ indicates complete equality, while $G=1$ indicates comple
311308---
312309mystnb:
313310 figure:
314- caption: "Shaded Lorenz curves ( simulated data) \n "
311+ caption: "Shaded lorenz curve of simulated data"
315312 name: lorenz_gini
316313 image:
317314 alt: lorenz_gini
@@ -335,8 +332,7 @@ ax.set_ylim((0, 1))
335332ax.set_xlim((0, 1))
336333
337334ax.text(0.04, 0.5, r'$G = 2 \times$ shaded area', fontsize=12)
338-
339- plt.title("Shaded lorenz curve of simulated data")
335+
340336plt.show()
341337```
342338
@@ -374,7 +370,7 @@ for σ in σ_vals:
374370```
375371
376372``` {code-cell} ipython3
377- def plot_inequality_measures(x, y, legend, xlabel, ylabel, title ):
373+ def plot_inequality_measures(x, y, legend, xlabel, ylabel):
378374
379375 fig, ax = plt.subplots()
380376 ax.plot(x, y, marker='o', label=legend)
@@ -383,27 +379,25 @@ def plot_inequality_measures(x, y, legend, xlabel, ylabel, title):
383379 ax.set_ylabel(ylabel, fontsize=12)
384380
385381 ax.legend(fontsize=12)
386- plt.title(title) # TODO shift it to the render
387382 plt.show()
388383```
389384
390385``` {code-cell} ipython3
391386---
392387mystnb:
393388 figure:
394- caption: "Lorenz curves ( simulated data) \n "
395- name: lorenz_simulated_shaded
389+ caption: "Gini coefficients of simulated data"
390+ name: gini_simulated
396391 image:
397- alt: gini
392+ alt: gini_simulated
398393 classes: shadow bg-primary
399394 width: 75%
400395---
401396plot_inequality_measures(range(k),
402397 ginis,
403398 'simulated',
404399 '$\sigma$',
405- 'gini coefficients',
406- 'Gini coefficients of simulated data')
400+ 'gini coefficients')
407401```
408402
409403The plots show that inequality rises with $\sigma$, according to the Gini
@@ -467,10 +461,10 @@ ginis_li_new[5] = (ginis_li[4] + ginis_li[6]) / 2
467461---
468462mystnb:
469463 figure:
470- caption: "US Gini Coefficients \n "
471- name: gini_us
464+ caption: "Gini coefficients of US net wealth "
465+ name: gini_wealth_us
472466 image:
473- alt: gini_us
467+ alt: gini_wealth_us
474468 classes: shadow bg-primary
475469 width: 75%
476470---
@@ -483,13 +477,21 @@ ax.plot(years, ginis_nw, marker='o')
483477
484478ax.set_xlabel(xlabel, fontsize=12)
485479ax.set_ylabel(ylabel, fontsize=12)
486-
487-
488- plt.title("Gini coefficients of US net wealth data")
480+
489481plt.show()
490482```
491483
492484``` {code-cell} ipython3
485+ ---
486+ mystnb:
487+ figure:
488+ caption: "Gini coefficients of US income"
489+ name: gini_income_us
490+ image:
491+ alt: gini_income_us
492+ classes: shadow bg-primary
493+ width: 75%
494+ ---
493495xlabel = "year"
494496ylabel = "gini coefficient"
495497
@@ -501,8 +503,7 @@ ax.plot(years, ginis_ti, marker='o', label="total income")
501503ax.set_xlabel(xlabel, fontsize=12)
502504ax.set_ylabel(ylabel, fontsize=12)
503505
504- ax.legend(fontsize=12)
505- plt.title("Gini coefficients of US income data")
506+ ax.legend(fontsize=12)
506507plt.show()
507508```
508509
@@ -590,6 +591,16 @@ df_topshares = df5[['year', 'topshare_n_wealth', 'topshare_t_income', 'topshare_
590591Then let's plot the top shares.
591592
592593```{code-cell} ipython3
594+ ---
595+ mystnb:
596+ figure:
597+ caption: "US top shares"
598+ name: top_shares_us
599+ image:
600+ alt: top_shares_us
601+ classes: shadow bg-primary
602+ width: 75%
603+ ---
593604xlabel = "year"
594605ylabel = "top $10\%$ share"
595606
@@ -603,7 +614,6 @@ ax.set_xlabel(xlabel, fontsize=12)
603614ax.set_ylabel(ylabel, fontsize=12)
604615
605616ax.legend(fontsize=12)
606- plt.title("Top shares of US data") # TODO shift to the render
607617plt.show()
608618```
609619
@@ -662,12 +672,21 @@ for σ in σ_vals:
662672```
663673
664674```{code-cell} ipython3
675+ ---
676+ mystnb:
677+ figure:
678+ caption: "Top shares of simulated data"
679+ name: top_shares_simulated
680+ image:
681+ alt: top_shares_simulated
682+ classes: shadow bg-primary
683+ width: 75%
684+ ---
665685plot_inequality_measures(range(len(topshares)),
666686 topshares,
667687 "simulated data",
668688 "year",
669- "top $10\%$ share",
670- "Top $10\%$ share of simulated data")
689+ "top $10\%$ share")
671690```
672691
673692```{solution-end}
@@ -708,6 +727,16 @@ for f_val, l_val in zip(f_vals_nw, l_vals_nw):
708727```
709728
710729```{code-cell} ipython3
730+ ---
731+ mystnb:
732+ figure:
733+ caption: "US top shares: approximation vs Lorenz"
734+ name: top_shares_us_al
735+ image:
736+ alt: top_shares_us_al
737+ classes: shadow bg-primary
738+ width: 75%
739+ ---
711740xlabel = "year"
712741ylabel = "top $10\%$ share"
713742
@@ -720,7 +749,6 @@ ax.set_xlabel(xlabel, fontsize=12)
720749ax.set_ylabel(ylabel, fontsize=12)
721750
722751ax.legend(fontsize=12)
723- plt.title("Top $10\%$ share of net wealth: approximation vs lorenz")
724752plt.show()
725753```
726754
0 commit comments