├── requirements.txt ├── images ├── bars.png ├── circles.png ├── two-series-0.png └── two-series-1.png ├── .gitignore ├── README.md ├── LICENSE ├── solutions └── Python-Data-Visualization-Solutions.ipynb ├── lessons └── Python-Data-Visualization.ipynb └── data └── gapminder.tsv /requirements.txt: -------------------------------------------------------------------------------- 1 | seaborn 2 | pandas 3 | numpy 4 | matplotlib 5 | jupyter 6 | pyprojroot -------------------------------------------------------------------------------- /images/bars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/Python-Data-Visualization-Legacy/HEAD/images/bars.png -------------------------------------------------------------------------------- /images/circles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/Python-Data-Visualization-Legacy/HEAD/images/circles.png -------------------------------------------------------------------------------- /images/two-series-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/Python-Data-Visualization-Legacy/HEAD/images/two-series-0.png -------------------------------------------------------------------------------- /images/two-series-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlab-berkeley/Python-Data-Visualization-Legacy/HEAD/images/two-series-1.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | # Jupyter Checkpoints 60 | .ipynb_checkpoints -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # D-Lab's Python Data Visualization Workshop 2 | 3 | This repository contains the materials for D-Lab's Python Data Visualization workshop. Prior experience with [Python Fundamentals](https://github.com/dlab-berkeley/python-fundamentals) is assumed. 4 | 5 | ## Workshop Goals 6 | 7 | In this workshop, we provide an introduction to data visualization with Python. First, we'll cover some basics of visualization theory. Then, we'll explore how to plot data in Python using the `matplotlib` and `seaborn` packages. We aim to cover the following types of plots: 8 | 9 | * line plots 10 | * bar plots 11 | * scatter plots 12 | * boxplot 13 | * heat maps 14 | 15 | We'll also learn how to customize and style plots. Throughout the workshop, we'll discuss the plot types best suited for particular kinds of data. 16 | 17 | Basic familiarity with Python *is* assumed. If you are not familiar with the material in [Python Fundamentals](https://github.com/dlab-berkeley/python-fundamentals), we recommend attending that workshop first. 18 | 19 | ## Installation Instructions 20 | 21 | Anaconda is a useful package management software that allows you to run Python and Jupyter notebooks very easily. Installing Anaconda is the easiest way to make sure you have all the necessary software to run the materials for this workshop. Complete the following steps: 22 | 23 | 1. [Download and install Anaconda (Python 3.8 distribution)](https://www.anaconda.com/products/individual). Click "Download" and then click 64-bit "Graphical Installer" for your current operating system. 24 | 25 | 2. Download the [Python-Data-Visualization workshop materials](https://github.com/dlab-berkeley/Python-Data-Visualization): 26 | 27 | * Click the green "Code" button in the top right of the repository information. 28 | * Click "Download Zip". 29 | * Extract this file to a folder on your computer where you can easily access it (we recommend Desktop). 30 | 31 | 3. Optional: if you're familiar with `git`, you can instead clone this repository by opening a terminal and entering `git clone git@github.com:dlab-berkeley/Python-Data-Visualization.git`. 32 | 33 | ## Run the code 34 | 35 | Now that you have all the required software and materials, you need to run the code: 36 | 37 | 1. Open the Anaconda Navigator application. You should see the green snake logo appear on your screen. Note that this can take a few minutes to load up the first time. 38 | 39 | 2. Click the "Launch" button under "Jupyter Notebooks" and navigate through your file system to the `Python-Data-Visualization` folder you downloaded above. 40 | 41 | 3. Open the `lessons` folder, and click `Python-Data-Visualization.ipynb` to begin. 42 | 43 | 4. Press Shift + Enter (or Ctrl + Enter) to run a cell. 44 | 45 | 5. By default, the necessary packages for this workshop should already be installed. You can install them within the Jupyter notebook by running the following line in its own cell: 46 | 47 | > ```!pip install -r requirements.txt``` 48 | 49 | Note that all of the above steps can be run from the terminal, if you're familiar with how to interact with Anaconda in that fashion. However, using Anaconda Navigator is the easiest way to get started if this is your first time working with Anaconda. 50 | 51 | ## Is Python not working on your laptop? 52 | 53 | If you do not have Anaconda installed and the materials loaded on your workshop by the time it starts, we *strongly* recommend using the UC Berkeley Datahub to run the materials for these lessons. You can access the DataHub by clicking this button: 54 | 55 | [![Datahub](https://img.shields.io/badge/launch-datahub-blue)](https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fdlab-berkeley%2FPython-Data-Visualization&urlpath=tree%2FPython-Data-Visualization%2F&branch=main) 56 | 57 | The DataHub downloads this repository, along with any necessary packages, and allows you to run the materials in a Jupyter notebook that is stored on UC Berkeley's servers. No installation is necessary from your end - you only need an internet browser and a CalNet ID to log in. By using the DataHub, you can save your work and come back to it at any time. When you want to return to your saved work, just go straight to [DataHub](https://datahub.berkeley.edu), sign in, and you click on the `Python-Data-Visualization` folder. 58 | 59 | If you don't have a Berkeley CalNet ID, you can still run these lessons in the cloud, by clicking this button: 60 | 61 | [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/dlab-berkeley/Python-Data-Visualization/HEAD) 62 | 63 | By using this button, however, you cannot save your work. 64 | 65 | # Additional Resources 66 | 67 | Check out the following resources to learn more about data visualization: 68 | 69 | * [Matplotlib tutorials](https://matplotlib.org/stable/tutorials/index.html) 70 | 71 | * [Seaborn tutorials](https://seaborn.pydata.org/tutorial.html) 72 | 73 | * Go further with the [plotly](https://plotly.com/), [bokeh](http://docs.bokeh.org/en/latest/), and [dash](https://plotly.com/dash/) packages. 74 | 75 | # About the UC Berkeley D-Lab 76 | 77 | D-Lab works with Berkeley faculty, research staff, and students to advance data-intensive social science and humanities research. Our goal at D-Lab is to provide practical training, staff support, resources, and space to enable you to use R for your own research applications. Our services cater to all skill levels and no programming, statistical, or computer science backgrounds are necessary. We offer these services in the form of workshops, one-to-one consulting, and working groups that cover a variety of research topics, digital tools, and programming languages. 78 | 79 | Visit the [D-Lab homepage](https://dlab.berkeley.edu/) to learn more about us. You can view our [calendar](https://dlab.berkeley.edu/events/calendar) for upcoming events, learn about how to utilize our [consulting](https://dlab.berkeley.edu/consulting) and [data](https://dlab.berkeley.edu/data) services, and check out upcoming [workshops](https://dlab.berkeley.edu/events/workshops). 80 | 81 | # Other D-Lab Python Workshops 82 | 83 | Here are other Python workshops offered by the D-Lab: 84 | 85 | ### Basic competency 86 | 87 | * [Python Fundamentals](https://github.com/dlab-berkeley/python-fundamentals) 88 | * [Introduction to Pandas](https://github.com/dlab-berkeley/introduction-to-pandas) 89 | * [Geospatial Fundamentals in Python](https://github.com/dlab-berkeley/Geospatial-Fundamentals-in-Python) 90 | 91 | ### Intermediate/advanced competency 92 | 93 | * [Computational Text Analysis in Python](https://github.com/dlab-berkeley/computational-text-analysis-spring-2019) 94 | * [Introduction to Machine Learning in Python](https://github.com/dlab-berkeley/python-machine-learning) 95 | * [Introduction to Artificial Neural Networks in Python](https://github.com/dlab-berkeley/ANN-Fundamentals) 96 | * [Fairness and Bias in Machine Learning](https://github.com/dlab-berkeley/fairML) 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Creative Commons Attribution-NonCommercial 4.0 International Public License 3 | 4 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 5 | 6 | Section 1 – Definitions. 7 | 8 | Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 9 | Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 10 | Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 11 | Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 12 | Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 13 | Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 14 | Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 15 | Licensor means the individual(s) or entity(ies) granting rights under this Public License. 16 | NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 17 | Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 18 | Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 19 | You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 20 | Section 2 – Scope. 21 | 22 | License grant. 23 | Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 24 | reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 25 | produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 26 | Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 27 | Term. The term of this Public License is specified in Section 6(a). 28 | Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 29 | Downstream recipients. 30 | Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 31 | No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 32 | No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 33 | Other rights. 34 | 35 | Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 36 | Patent and trademark rights are not licensed under this Public License. 37 | To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 38 | Section 3 – License Conditions. 39 | 40 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 41 | 42 | Attribution. 43 | 44 | If You Share the Licensed Material (including in modified form), You must: 45 | 46 | retain the following if it is supplied by the Licensor with the Licensed Material: 47 | identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 48 | a copyright notice; 49 | a notice that refers to this Public License; 50 | a notice that refers to the disclaimer of warranties; 51 | a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 52 | indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 53 | indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 54 | You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 55 | If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 56 | If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 57 | Section 4 – Sui Generis Database Rights. 58 | 59 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 60 | 61 | for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 62 | if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 63 | You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 64 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 65 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 66 | 67 | Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 68 | To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 69 | The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 70 | Section 6 – Term and Termination. 71 | 72 | This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 73 | Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 74 | 75 | automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 76 | upon express reinstatement by the Licensor. 77 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 78 | For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 79 | Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 80 | Section 7 – Other Terms and Conditions. 81 | 82 | The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 83 | Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 84 | Section 8 – Interpretation. 85 | 86 | For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 87 | To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 88 | No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 89 | Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 90 | -------------------------------------------------------------------------------- /solutions/Python-Data-Visualization-Solutions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Data Visualization using Python: Solutions" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "## Import Packages" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "import numpy as np\n", 24 | "import pandas as pd\n", 25 | "import matplotlib as mpl\n", 26 | "import matplotlib.pyplot as plt\n", 27 | "\n", 28 | "from pyprojroot import here\n", 29 | "\n", 30 | "%matplotlib inline" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "## Import the Data Set" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "gm = pd.read_csv(here('data/gapminder.tsv'), sep='\\t')" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "## Challenge Questions: Histograms\n" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "latest_year = gm['year'].max()\n", 63 | "gm_latest = gm[gm['year'] == latest_year]" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "1. Create a histogram of life expectancy in the year 2007 across all 142 countries in the gapminder dataset. Play with the `bins=` parameter to find the most informative bin number." 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [ 79 | "# Try 17 bins\n", 80 | "plt.hist(gm_latest['lifeExp'], bins=17)\n", 81 | "plt.title('Distribution of Global Life Expectancy in 2007')\n", 82 | "plt.xlabel('Life Expectancy (Years)')\n", 83 | "plt.ylabel('# of Countries');" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [ 92 | "# Try 25 bins\n", 93 | "plt.hist(gm_latest['lifeExp'], bins=25)\n", 94 | "plt.title('Distribution of Global Life Expectancy in 2007')\n", 95 | "plt.xlabel('Life Expectancy (Years)')\n", 96 | "plt.ylabel('# of Countries');" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": null, 102 | "metadata": {}, 103 | "outputs": [], 104 | "source": [ 105 | "# Try 10 bins\n", 106 | "plt.hist(gm_latest['lifeExp'], bins=10)\n", 107 | "plt.title('Distribution of Global Life Expectancy in 2007')\n", 108 | "plt.xlabel('Life Expectancy (Years)')\n", 109 | "plt.ylabel('# of Countries');" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "2. What can you say about the distribution of life expectancy values in 2007?\n", 117 | "\n", 118 | "Three peaks: one at the lower end (around 50-60), one around 70, and one around 80. There are many countries with lower life expectancy, and another group with very high life expectancy." 119 | ] 120 | }, 121 | { 122 | "cell_type": "markdown", 123 | "metadata": {}, 124 | "source": [ 125 | "## Challenge Questions: Bar Plots" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [ 134 | "countries = gm[['country', 'continent']]\n", 135 | "countries = countries.drop_duplicates()\n", 136 | "country_counts = countries.groupby('continent', as_index=False).agg('count')\n", 137 | "country_counts.columns = ['continent', 'n_countries']\n", 138 | "continents = country_counts['continent']" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "# Get the countries in Oceania in 2007\n", 148 | "gm_latest_oceania = gm_latest[gm_latest['continent'] == 'Oceania']\n", 149 | "gm_latest_oceania" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "3. Create a bar plot showing the per-capita GDP for all the countries in Oceania during 2007." 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": null, 162 | "metadata": {}, 163 | "outputs": [], 164 | "source": [ 165 | "plt.bar(range(len(gm_latest_oceania)), gm_latest_oceania['gdpPercap'])\n", 166 | "plt.xticks(range(len(gm_latest_oceania)), gm_latest_oceania['country']);" 167 | ] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "metadata": {}, 172 | "source": [ 173 | "4. **\\[OPTIONAL\\]**. The above bar plot shows the counts of countries in each continent. We might be interested in the proportion of countries that exist in each of the 5 continents. Do a web search for `plt.pie` and figure out how to make a pie plot that displays proportions of all countries contained in each of the 5 continents." 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "plt.pie(country_counts['n_countries'], labels=continents, autopct='%.01f')\n", 183 | "plt.title('Proportion of countries per continent.');" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "## Challenge Questions: Boxplots" 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "metadata": {}, 196 | "source": [ 197 | "5. Knowing how to interpret your plots is almost as important as knowing how to make them! Looking at the above box plot of per-capita GDP for each continent, what information do you take away from it? Where do you think the U.S.A is represented in this plot? And how could you confirm that?" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": null, 203 | "metadata": {}, 204 | "outputs": [], 205 | "source": [ 206 | "gm_latest[gm_latest['country'] == 'United States']" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "metadata": {}, 212 | "source": [ 213 | "## Challenge Questions: Line Plots" 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": null, 219 | "metadata": {}, 220 | "outputs": [], 221 | "source": [ 222 | "portugal = gm[gm['country'] == 'Portugal']\n", 223 | "spain = gm[gm['country'] == 'Spain']" 224 | ] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "metadata": {}, 229 | "source": [ 230 | "6. Create another line plot showing the life expectancy for Spain and Portugal across all the years in the dataset similar to the one above, but try to add some customizations (e.g., changing the font sizes, different line colors, etc.). You can use the `help()` function to see what kind of customizations are available." 231 | ] 232 | }, 233 | { 234 | "cell_type": "code", 235 | "execution_count": null, 236 | "metadata": {}, 237 | "outputs": [], 238 | "source": [ 239 | "plt.figure(figsize=(10, 5))\n", 240 | "plt.plot(spain['year'], spain['lifeExp'], label='Spain', color='blue')\n", 241 | "plt.plot(portugal['year'], portugal['lifeExp'], label='Portugal', color='green')\n", 242 | "plt.title('Life Expectancy of Portugal & Spain', fontsize=18)\n", 243 | "plt.xlabel('Time (Years)', fontsize=14)\n", 244 | "plt.ylabel('Life Expectancy (Years)', fontsize=14)\n", 245 | "plt.legend(prop={'size': 13});" 246 | ] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "metadata": {}, 251 | "source": [ 252 | "7. Does Spain or Portugal have a higher life expectancy across all the years? How does this relate to per-capita GDP? How might we look for a relationship?\n", 253 | "\n", 254 | "Spain has a higher life expectancy. We could create a line plot between life expectancy and per-capita GDP." 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "## Challenge Questions: Scatter Plots" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "metadata": {}, 267 | "source": [ 268 | "8. We've seen that life expectancy and per-capita GDP have a positive relationship. What about the relationship between population and per-capita GDP, is there one? Create a scatter plot that compares the two across all countries in 2007. " 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "plt.scatter(np.log10(gm_latest['gdpPercap']), gm_latest['pop'], marker='.')\n", 278 | "plt.xlabel('Per-Capita GDP (Millions $USD)')\n", 279 | "plt.yscale('log')\n", 280 | "plt.ylabel('Population');" 281 | ] 282 | }, 283 | { 284 | "cell_type": "markdown", 285 | "metadata": {}, 286 | "source": [ 287 | "9. Is that relationship between population and per-capita GDP different for the first year we have data in the dataset? Plot both first and latest years scatter next to each other in the same figure but different subplots. What can you say about any outliers you see?\n", 288 | "\n", 289 | "(*HINT*: First you need to extract another `DataFrame` containing the data from the first year)." 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "execution_count": null, 295 | "metadata": {}, 296 | "outputs": [], 297 | "source": [ 298 | "first_year = gm['year'].min()\n", 299 | "print(first_year)\n", 300 | "gm_first = gm[gm['year']== first_year]" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": null, 306 | "metadata": {}, 307 | "outputs": [], 308 | "source": [ 309 | "plt.figure(figsize=(15,5))\n", 310 | "\n", 311 | "plt.subplot(1,2,1)\n", 312 | "plt.scatter(np.log10(gm_first['gdpPercap']), gm_first['pop'], marker='.')\n", 313 | "plt.title('1952')\n", 314 | "plt.xlabel('Per-Capita GDP (Millions $USD)')\n", 315 | "plt.yscale('log')\n", 316 | "plt.ylabel('Population');\n", 317 | "\n", 318 | "plt.subplot(1,2,2)\n", 319 | "plt.scatter(np.log10(gm_latest['gdpPercap']), gm_latest['pop'], marker='.')\n", 320 | "plt.title('2007')\n", 321 | "plt.xlabel('Per-Capita GDP (Millions $USD)')\n", 322 | "plt.yscale('log')\n", 323 | "plt.ylabel('Population');" 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": {}, 329 | "source": [ 330 | "#### Pandas approach\n", 331 | "\n", 332 | "Here are a pair of plots related to (but not directly answering) the above questions, using Pandas methods again." 333 | ] 334 | }, 335 | { 336 | "cell_type": "code", 337 | "execution_count": null, 338 | "metadata": {}, 339 | "outputs": [], 340 | "source": [ 341 | "min_yr = gm.year.min()\n", 342 | "gm_first_yr = gm[gm.year == min_yr]\n", 343 | "gm.plot(x = 'gdpPercap', y='pop', kind='scatter', figsize=(10,8))\n", 344 | "plt.xlabel('GDP per capita')\n", 345 | "plt.ylabel('Population')\n", 346 | "plt.title('Population vs. GPD per capita, first year');" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": null, 352 | "metadata": {}, 353 | "outputs": [], 354 | "source": [ 355 | "gm.plot(x = 'gdpPercap', y='pop', c='year', cmap='spring', kind='scatter', figsize=(10,8))\n", 356 | "plt.xlabel('GDP per capita')\n", 357 | "plt.ylabel('Population')\n", 358 | "plt.title('Population vs. GPD per capita, across years');" 359 | ] 360 | }, 361 | { 362 | "cell_type": "markdown", 363 | "metadata": {}, 364 | "source": [ 365 | "10. **\\[OPTIONAL\\]** Above we created a scatter plot between life expectancy and per-capita GDP colored by year. That coloring was done in a continuous way. What if we wanted to color it by decade instead, making a discrete coloring? Run the code cell below to create a new variable called `decades`. Then create another scatter plot of life expectancy vs per-capita GDP assigning the color strings in `hexsix` to data points from each of the six decades in the dataset. " 366 | ] 367 | }, 368 | { 369 | "cell_type": "code", 370 | "execution_count": null, 371 | "metadata": {}, 372 | "outputs": [], 373 | "source": [ 374 | "hexsix = np.array(['#ffffcc', '#d9f0a3', '#addd8e', '#78c679', '#31a354', '#006837'])\n", 375 | "gm['decade'] = (gm['year'] / 10).astype(int) * 10\n", 376 | "decades = gm['decade'].unique()\n", 377 | "decades" 378 | ] 379 | }, 380 | { 381 | "cell_type": "markdown", 382 | "metadata": {}, 383 | "source": [ 384 | "You could also apply a special temporary kind of function called a `lambda` function to every item in the year column to create the decades. See [here](https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions) for more on lambda functions." 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": null, 390 | "metadata": {}, 391 | "outputs": [], 392 | "source": [ 393 | "gm['decade'] = gm['year'].apply(lambda x: int(x / 10) * 10)" 394 | ] 395 | }, 396 | { 397 | "cell_type": "code", 398 | "execution_count": null, 399 | "metadata": {}, 400 | "outputs": [], 401 | "source": [ 402 | "for i,cur_decade in enumerate(decades):\n", 403 | " cur_decade_gm = gm[gm['decade']==cur_decade]\n", 404 | " plt.scatter(np.log10(cur_decade_gm['gdpPercap']), \n", 405 | " cur_decade_gm['lifeExp'], \n", 406 | " marker='.', \n", 407 | " color=hexsix[i], \n", 408 | " label=str(cur_decade))\n", 409 | "plt.legend();" 410 | ] 411 | } 412 | ], 413 | "metadata": { 414 | "hide_input": false, 415 | "kernelspec": { 416 | "display_name": "Python 3 (ipykernel)", 417 | "language": "python", 418 | "name": "python3" 419 | }, 420 | "language_info": { 421 | "codemirror_mode": { 422 | "name": "ipython", 423 | "version": 3 424 | }, 425 | "file_extension": ".py", 426 | "mimetype": "text/x-python", 427 | "name": "python", 428 | "nbconvert_exporter": "python", 429 | "pygments_lexer": "ipython3", 430 | "version": "3.8.12" 431 | }, 432 | "toc": { 433 | "base_numbering": 1, 434 | "nav_menu": {}, 435 | "number_sections": false, 436 | "sideBar": true, 437 | "skip_h1_title": false, 438 | "title_cell": "Table of Contents", 439 | "title_sidebar": "Contents", 440 | "toc_cell": false, 441 | "toc_position": { 442 | "height": "calc(100% - 180px)", 443 | "left": "10px", 444 | "top": "150px", 445 | "width": "235px" 446 | }, 447 | "toc_section_display": true, 448 | "toc_window_display": true 449 | }, 450 | "varInspector": { 451 | "cols": { 452 | "lenName": 16, 453 | "lenType": 16, 454 | "lenVar": 40 455 | }, 456 | "kernels_config": { 457 | "python": { 458 | "delete_cmd_postfix": "", 459 | "delete_cmd_prefix": "del ", 460 | "library": "var_list.py", 461 | "varRefreshCmd": "print(var_dic_list())" 462 | }, 463 | "r": { 464 | "delete_cmd_postfix": ") ", 465 | "delete_cmd_prefix": "rm(", 466 | "library": "var_list.r", 467 | "varRefreshCmd": "cat(var_dic_list()) " 468 | } 469 | }, 470 | "types_to_exclude": [ 471 | "module", 472 | "function", 473 | "builtin_function_or_method", 474 | "instance", 475 | "_Feature" 476 | ], 477 | "window_display": false 478 | } 479 | }, 480 | "nbformat": 4, 481 | "nbformat_minor": 4 482 | } 483 | -------------------------------------------------------------------------------- /lessons/Python-Data-Visualization.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Theory of Data Visualization\n", 8 | "\n", 9 | "Visualization is meant to convey information.\n", 10 | "\n", 11 | "> The power of a graph is its ability to enable one to take in the quantitative information, organize it, and see patterns and structure not readily revealed by other means of studying the data.\n", 12 | "\n", 13 | "\\- Cleveland and McGill, 1984\n", 14 | "\n", 15 | "Certain techniques make that information easier to interpret and understand. In their 1984 paper titled, \"[Graphical Perception: Theory, Experimentation, and Application to the Development of Graphical Methods](https://www-jstor-org.libproxy.berkeley.edu/stable/2288400?seq=1#page_scan_tab_contents),\" Cleveland and McGill identify 10 elementary perceptual tasks that are used to \"extract quantitative information from graphs.\" Their premise is:\n", 16 | "\n", 17 | "> A graphical form that involves elementary perceptual tasks that lead to more accurate judgments than another graphical form (with the same quantitative information) will result in better organization and increase the chances of a correct perception of patterns and behavior.\n", 18 | "\n", 19 | "Whereas graph design had, up to that point, been \"largely unscientific,\" Cleveland and McGill took a systematic approach in analyzing human graphical perception through experimentation. Their researched helped identify the most and least accurate elementary perceptual tasks, ordered below:\n", 20 | "\n", 21 | "1. Position along a common scale\n", 22 | "2. Position along non-aligned scales\n", 23 | "3. Length, direction, angle\n", 24 | "4. Area\n", 25 | "5. Volume, curvature\n", 26 | "6. Shading, color saturation\n", 27 | "\n", 28 | "In 2010, [Heer and Bostock](http://vis.stanford.edu/files/2010-MTurk-CHI.pdf) confirmed these results using Amazon's Mechanical Turk.\n", 29 | "\n", 30 | "Let's take a look at a few examples. Because we're only interested in relative sizes, we don't include a legend with size information or reference points." 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "![circles](../images/circles.png)" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "For circles of distinctly different sizes, the comparison is simple. For example, \"A\" is smaller than \"B.\" However, for circles, such as \"L\" and \"M,\" that are almost the same size, it's difficult to tell which is smaller. Area, according to Cleveland and McGill's research, is less accurate than, say, length, which we consider next." 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "![bars](../images/bars.png)" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "Focusing on \"L\" and \"M,\" it is clear to see which is larger. You might be wondering whether scale makes a difference—that is, if the small circle sizes make it difficult to compare. It doesn't.\n", 59 | "\n", 60 | "Next, we consider a case where we want to plot two series. For this example, let's suppose we're working with student English and math test scores. Here, we'll want to use bars, which we arbitrarily label Z-L. The question is, which bars should we use? This is a case where the answer depends on what we're trying to communicate. If we're interested in showing total scores, we could use a stacked bar chart." 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "![two_bars](../images/two-series-0.png)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": {}, 73 | "source": [ 74 | "We can tell that \"Y\" and \"L\" had the highest cumulative scores. What if we want to know which students scored highest on the math exam? Because the math portions of each bar are on \"non-aligned scales,\" as Cleveland and McGill call it, it's difficult to tell. One solution is to plot these on opposite sides of the x-axis." 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": {}, 80 | "source": [ 81 | "![two_bars_centered](../images/two-series-1.png)" 82 | ] 83 | }, 84 | { 85 | "cell_type": "markdown", 86 | "metadata": {}, 87 | "source": [ 88 | "Now, it's easier to see that \"R\" scored quite well on the math exam. The tradeoff with this layout is that it's difficult to compare cumulative scores. Comparing \"Z\" and \"O,\" for example, is a challenge. Again, it depends on what the message is.\n", 89 | "\n", 90 | "These findings are a *guide* for what works when the goal is to make accurate judgments. Sometimes, however, the goal might not be to allow for precise comparisons but, rather, to facilitate the perception of larger patterns." 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "## Form and Function\n", 98 | "\n", 99 | "> A good graphic realizes two basic goals: It **presents** information, and it allows users to **explore** that information.\n", 100 | "\n", 101 | "\\- Alberto Cairo\n", 102 | "\n", 103 | "-------------------------\n", 104 | "\n", 105 | "> A data visualization should only be beautiful when beauty can promote understanding in some way without undermining it in another. Is beauty sometimes useful? Certainly. Is beauty always useful? Certainly not.\n", 106 | "\n", 107 | "\\- Stephen Few\n", 108 | "\n", 109 | "-------------------------\n", 110 | "\n", 111 | "> Good displays of data help to reveal knowledge relevant to understanding mechanism, process and dynamics, cause and effect.\n", 112 | "\n", 113 | "\\- Edward Tufte\n", 114 | "\n", 115 | "-------------------------\n", 116 | "\n", 117 | ">A figure is ineffective if it \"wastes too much real estate (and the designer's time) on things that don't help readers understand [it].\" \n", 118 | "\n", 119 | "\\- Alberto Cairo\n", 120 | "\n", 121 | "-------------------------\n", 122 | "\n", 123 | "> The important criterion for a graph is not simply how fast we can see a result; rather it is whether through the use of the graph we can see something that would have been harder to see otherwise or that could not have been seen at all.\n", 124 | "\n", 125 | "\\- William Cleveland\n", 126 | "\n", 127 | "-------------------------\n", 128 | "\n", 129 | "> [A]lways take advantage of the space you have available to seek depth within reasonable limits. After that, *and only after that*, worry about how to make the presentation prettier.\n", 130 | "\n", 131 | "\\- Alberto Cairo\n" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "----------------------" 139 | ] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "Ultimately, identify your audience and their needs and interests. The same data should be visualized differently for a scientific publication versus a magazine." 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "# Data Visualization using Python" 153 | ] 154 | }, 155 | { 156 | "cell_type": "markdown", 157 | "metadata": {}, 158 | "source": [ 159 | "## Matplotlib" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "Now, we'll start learning *how* to create visualizations in Python. We'll start by using a popular python package called `matplotlib`, and later on use a second package called `seaborn` that builds on `matplotlib` First we'll import `matplotlib`, along with several other Python packages we'll be using during this workshop." 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "import numpy as np\n", 176 | "import pandas as pd\n", 177 | "import matplotlib as mpl\n", 178 | "import matplotlib.pyplot as plt" 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "One of the nice features of Jupyter notebooks is that figures can be plotted inline, which means they appear below the code cell that creates them. This is not the default behavior however, and so we'll use the below **\"Magic\"** statement (these statements are added to solve simple problems) to tell the Jupyter notebook to plot the figures inline (instead of opening a separate browser window to show them)." 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": null, 191 | "metadata": {}, 192 | "outputs": [], 193 | "source": [ 194 | "%matplotlib inline" 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "### Import the Data Set" 202 | ] 203 | }, 204 | { 205 | "cell_type": "markdown", 206 | "metadata": {}, 207 | "source": [ 208 | "To illustrate what `matplotlib` and `seaborn` can do, we'll need to use a dataset. We've decided to use the so-called Gapminder dataset, which was compiled by Jennifer Bryan. This dataset contains several key demographic and economic statistics for many countries, across many years. For more information, see the [gapminder](https://github.com/jennybc/gapminder) repository.\n", 209 | "\n", 210 | "We'll use the `pandas` Python package to load the `.csv` (comma separated values) file that contains the dataset. The `pandas` package provides `DataFrame` objects that organize datasets in tabular form (think Microsoft Excel spreadsheets). We've created an alias for the `pandas` package, called `pd`, which is the convention. To read in a `.csv` file we simply use `pd.read_csv`. This `.csv` file happens to be tab-delimited, so we need to specify `sep=\\t`.\n", 211 | "\n", 212 | "Also, we're going to use the `pyprojroot` package to obtain the correct file path for the dataset (if you've used R, it's very similar to the `here` package). If you have not installed this package, you can do so within the Jupyter notebook:" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": null, 218 | "metadata": {}, 219 | "outputs": [], 220 | "source": [ 221 | "# Run if you need to install pyprojroot\n", 222 | "!pip install pyprojroot" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": null, 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [ 231 | "from pyprojroot import here" 232 | ] 233 | }, 234 | { 235 | "cell_type": "markdown", 236 | "metadata": {}, 237 | "source": [ 238 | "Then, the `here` function will allow us to easily specify the correct path:" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": null, 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [ 247 | "gm = pd.read_csv(here('data/gapminder.tsv'), sep='\\t')" 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "To look at the first few rows of the dataset we'll use the `.head()` method of the dataframe." 255 | ] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "execution_count": null, 260 | "metadata": {}, 261 | "outputs": [], 262 | "source": [ 263 | "gm.head()" 264 | ] 265 | }, 266 | { 267 | "cell_type": "markdown", 268 | "metadata": {}, 269 | "source": [ 270 | "It looks like we have information about life expectancy (`lifeExp`), population (`pop`) and per-capita GDP (`gdpPercap`), across multiple years per country. \n", 271 | "\n", 272 | "To start off, let's say we want to explore the data from the most recent year in the dataset. First we'll find the maximum value for year, and then create a second `DataFrame` containing data from only that year. We'll do that using Boolean Masking (for an introduction on how to use `pandas`, see the DLab's [\"Introduction to Pandas\" workshop](https://github.com/dlab-berkeley/introduction-to-pandas))" 273 | ] 274 | }, 275 | { 276 | "cell_type": "code", 277 | "execution_count": null, 278 | "metadata": {}, 279 | "outputs": [], 280 | "source": [ 281 | "latest_year = gm['year'].max()\n", 282 | "latest_year" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": null, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "gm_latest = gm[gm['year'] == latest_year]\n", 292 | "gm_latest.shape" 293 | ] 294 | }, 295 | { 296 | "cell_type": "markdown", 297 | "metadata": {}, 298 | "source": [ 299 | "Ok, looks like we have 142 values, or rows, across our 6 variables, or columns. Let's get an idea of how per-capita GDP was distributed across all of the countries during 2007 by calculating some **summary statistics**. We'll do that using the `DataFrame`'s `.describe()` method." 300 | ] 301 | }, 302 | { 303 | "cell_type": "code", 304 | "execution_count": null, 305 | "metadata": {}, 306 | "outputs": [], 307 | "source": [ 308 | "gm_latest['gdpPercap'].describe()" 309 | ] 310 | }, 311 | { 312 | "cell_type": "markdown", 313 | "metadata": {}, 314 | "source": [ 315 | "Across 142 countries the mean GDP was ~\\\\$11680, and the standard deviation was ~\\\\$12860! There was a lot of deviation in GDP across countries, but these summary statistics don't give us the whole picture. To get the whole picture, let's draw a picture! Or plot a figure, more accurately." 316 | ] 317 | }, 318 | { 319 | "cell_type": "markdown", 320 | "metadata": {}, 321 | "source": [ 322 | "### Histograms\n", 323 | "\n", 324 | "Histograms plot a discretized distribution of a one-dimensional dataset across all the values it has taken. They visualize how many of the data points are in each of $b$ bins, each of which has a pre-defined range. \n", 325 | "\n", 326 | "To create a histogram plot in `matplotlib` we'll use `pyplot`, which is a collection of command style functions that make matplotlib work like MATLAB and save many lines of repeated code. By convention, `pyplot` is aliased to `plt`, which we've already done in the above import cell. \n", 327 | "\n", 328 | "Let's use `plt.hist()` to create a histogram of the per-capita GDP in 2007." 329 | ] 330 | }, 331 | { 332 | "cell_type": "code", 333 | "execution_count": null, 334 | "metadata": {}, 335 | "outputs": [], 336 | "source": [ 337 | "plt.hist(gm_latest['gdpPercap']);" 338 | ] 339 | }, 340 | { 341 | "cell_type": "markdown", 342 | "metadata": {}, 343 | "source": [ 344 | "**Protip**: Use a semicolon (`;`) at the end of the last line in a Jupyter notebook cell to suppress the notebooks from printing the return value of the last line. This was done in the above cell. Try removing the `;` to see how the output changes.\n", 345 | "\n", 346 | "This histogram tells us that many of the countries had a low GDP, which was less than 5,000. There is also a second \"bump\" in the histogram around 30,000. This type of distribution is known as **bi-modal**, since there are two modes, or common values.\n", 347 | "\n", 348 | "To make this histogram more interpretable let's add a title and labels for the $x$ and $y$ axes. We'll pass strings to `plt.title()`, `plt.xlabel()`, and `plt.ylabel()` to do so." 349 | ] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": null, 354 | "metadata": {}, 355 | "outputs": [], 356 | "source": [ 357 | "plt.hist(gm_latest['gdpPercap'])\n", 358 | "plt.title('Distribution of Global Per-Capita GDP in 2007')\n", 359 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 360 | "plt.ylabel('# of Countries');" 361 | ] 362 | }, 363 | { 364 | "cell_type": "markdown", 365 | "metadata": {}, 366 | "source": [ 367 | "Each line in the histogram represents a bin. The height of the line represents the number of items (countries in this case) within the range of values spanned by the bin. In the last plots we used the default number of bins (10), now let's use more bins by specifying the `bin=30` parameter." 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": null, 373 | "metadata": {}, 374 | "outputs": [], 375 | "source": [ 376 | "plt.hist(gm_latest['gdpPercap'], bins=30)\n", 377 | "plt.title('Distribution of Global Per-Capita GDP in 2007')\n", 378 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 379 | "plt.ylabel('# of Countries');" 380 | ] 381 | }, 382 | { 383 | "cell_type": "markdown", 384 | "metadata": {}, 385 | "source": [ 386 | "We can see this histogram doesn't look as \"smooth\" as the last one. There's no \"right\" way to display a histogram, but some bin counts definitely are more informative than others. For example, using only 3 bins we cannot see the bi-modal nature of the GDP distribution." 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": null, 392 | "metadata": {}, 393 | "outputs": [], 394 | "source": [ 395 | "plt.hist(gm_latest['gdpPercap'], bins=3)\n", 396 | "plt.title('Distribution of Global Per-Capita GDP in 2007')\n", 397 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 398 | "plt.ylabel('# of Countries');" 399 | ] 400 | }, 401 | { 402 | "cell_type": "markdown", 403 | "metadata": {}, 404 | "source": [ 405 | "#### Multiple calls to `plt`\n", 406 | "\n", 407 | "As you can see, we can call functions in the `plt` module multiple times within a single cell and those functions will all work on, and modify, the current figure associated with the current cell. This is because `pyplot` (or `plt`) keeps an internal variable for the current figure which is unique to each cell `plt` is used in.\n", 408 | "\n", 409 | "**NOTE:** Unless specified in the help function, the order of these function calls doesn't matter. See that the cell below produces the same plot as the one above even though the calls to `plt` functions are in a different order." 410 | ] 411 | }, 412 | { 413 | "cell_type": "code", 414 | "execution_count": null, 415 | "metadata": {}, 416 | "outputs": [], 417 | "source": [ 418 | "plt.title('Distribution of Global Per-Capita GDP in 2007')\n", 419 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 420 | "plt.hist(gm_latest['gdpPercap'], bins=3)\n", 421 | "plt.ylabel('# of Countries');" 422 | ] 423 | }, 424 | { 425 | "cell_type": "markdown", 426 | "metadata": {}, 427 | "source": [ 428 | "The styling that you see in the plot above are the `matplotlib` defaults. For now, we'll continue to use those defaults as the first portion of this workshop is geared toward getting you familiar with the API-how to actually create the plots you're interested in. Then, we'll cover how to customize plot styles in a later section." 429 | ] 430 | }, 431 | { 432 | "cell_type": "markdown", 433 | "metadata": {}, 434 | "source": [ 435 | "#### Pandas methods to make plots\n", 436 | "\n", 437 | "Also note that when you are working with Pandas DataFrames you will have access to DataFrame methods to produce a lot of the same types of plots!\n", 438 | "\n", 439 | "These methods' plots are still produced by Matplotlib 'under the hood'. The methods often require less code than the Matplotlib approach, but they typically also provide less extensive customization. So they impose a **trade-off between convenience and customizability**.\n", 440 | "\n", 441 | "In order to present you with a range of plotting options, we will present you with Pandas-equivalent code for a number of the plots we demonstrate below. \n", 442 | "\n", 443 | "Here is the first, using the `DataFrame.hist` method:" 444 | ] 445 | }, 446 | { 447 | "cell_type": "code", 448 | "execution_count": null, 449 | "metadata": {}, 450 | "outputs": [], 451 | "source": [ 452 | "gm_latest.hist(column='gdpPercap', bins=3);" 453 | ] 454 | }, 455 | { 456 | "cell_type": "markdown", 457 | "metadata": {}, 458 | "source": [ 459 | "According to the docs, we can also get rid of that grid, if we'd like, by feeding in the `grid=False` argument\n", 460 | "(because it defaults to `True`)." 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": null, 466 | "metadata": {}, 467 | "outputs": [], 468 | "source": [ 469 | "gm_latest.hist(column='gdpPercap', bins=3, grid=False);" 470 | ] 471 | }, 472 | { 473 | "cell_type": "markdown", 474 | "metadata": {}, 475 | "source": [ 476 | "And we can also combine that call with some Matplotlib code, to get back our custom title and axis labels,\n", 477 | "giving us an identical plot to the one we produced above with *only* Matplotlib code." 478 | ] 479 | }, 480 | { 481 | "cell_type": "code", 482 | "execution_count": null, 483 | "metadata": {}, 484 | "outputs": [], 485 | "source": [ 486 | "gm_latest.hist(column='gdpPercap', bins=3, grid=False)\n", 487 | "plt.title('Distribution of Global Per-Capita GDP in 2007')\n", 488 | "plt.xlabel('Per-Capita GDP (Millions of USD)')\n", 489 | "plt.ylabel('# of Countries');" 490 | ] 491 | }, 492 | { 493 | "cell_type": "markdown", 494 | "metadata": {}, 495 | "source": [ 496 | "#### Challenge Questions\n", 497 | "\n", 498 | "1. Create a histogram of life expectancy in the year 2007 across all 142 countries in the gapminder dataset. Play with the `bins=` parameter to find the most informative bin number." 499 | ] 500 | }, 501 | { 502 | "cell_type": "code", 503 | "execution_count": null, 504 | "metadata": {}, 505 | "outputs": [], 506 | "source": [] 507 | }, 508 | { 509 | "cell_type": "markdown", 510 | "metadata": {}, 511 | "source": [ 512 | "2. What can you say about the distribution of life expectancy values in 2007?" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": null, 518 | "metadata": {}, 519 | "outputs": [], 520 | "source": [] 521 | }, 522 | { 523 | "cell_type": "markdown", 524 | "metadata": {}, 525 | "source": [ 526 | "### Bar Plots" 527 | ] 528 | }, 529 | { 530 | "cell_type": "markdown", 531 | "metadata": {}, 532 | "source": [ 533 | "Next, it might be interesting to get a sense of how many countries per continent we have data for. Let's create a country `DataFrame` that includes only the unique combinations of country and continent by dropping all duplicate rows using `drop_duplicates()`" 534 | ] 535 | }, 536 | { 537 | "cell_type": "code", 538 | "execution_count": null, 539 | "metadata": {}, 540 | "outputs": [], 541 | "source": [ 542 | "countries = gm[['country', 'continent']]\n", 543 | "countries = countries.drop_duplicates()" 544 | ] 545 | }, 546 | { 547 | "cell_type": "code", 548 | "execution_count": null, 549 | "metadata": {}, 550 | "outputs": [], 551 | "source": [ 552 | "countries.shape" 553 | ] 554 | }, 555 | { 556 | "cell_type": "markdown", 557 | "metadata": {}, 558 | "source": [ 559 | "To get the number of countries per continent we'll use the `.groupby()` method to group by `continent`, then count the unique countries in each continent. We'll use the `as_index=False` argument so that the continent name gets its own column, and is not used as the index. This will create a new `DataFrame` that we'll call `country_counts`." 560 | ] 561 | }, 562 | { 563 | "cell_type": "code", 564 | "execution_count": null, 565 | "metadata": {}, 566 | "outputs": [], 567 | "source": [ 568 | "country_counts = countries.groupby('continent', as_index=False).agg('count')\n", 569 | "country_counts" 570 | ] 571 | }, 572 | { 573 | "cell_type": "markdown", 574 | "metadata": {}, 575 | "source": [ 576 | "Let's rename the `country` column to be `n_countries` for number of countries." 577 | ] 578 | }, 579 | { 580 | "cell_type": "code", 581 | "execution_count": null, 582 | "metadata": {}, 583 | "outputs": [], 584 | "source": [ 585 | "country_counts.columns = ['continent', 'n_countries']\n", 586 | "country_counts" 587 | ] 588 | }, 589 | { 590 | "cell_type": "markdown", 591 | "metadata": {}, 592 | "source": [ 593 | "Let's use a **bar plot** to plot this data, which we saw in the theory section is an effective way to compare the magnitudes of a number of data points on the same scale. Bar plots look a lot like histograms, but differ in that they do not represent a distribution of data, rather a collection of data points. \n", 594 | "\n", 595 | "Making a bar plot in `matplotlib` is done conveniently using `plt.bar`. This takes two arguments, the first is the location on the $x$-axis that the bars should appear, and the second is the height of each bar on the $y$-axis, which in our case is equal to `n_countries`. Since we want the bars to appear equidistant from each other, we'll create a sequence of increasing numbers going from `0` to the number of bars we want plotted (# of continents, or `len(continents)` here) using the `range` function. \n", 596 | "\n", 597 | "Let's also use `plt.xticks()` and the continent names to label the $x$-ticks, which are the text below each bar on the $x$-axis. The `plt.xticks()` function takes two arguments. The first is the *position* for the label and the second is the label itself. The arguments are container-like objects, such as `list`s or `numpy` arrays. " 598 | ] 599 | }, 600 | { 601 | "cell_type": "code", 602 | "execution_count": null, 603 | "metadata": {}, 604 | "outputs": [], 605 | "source": [ 606 | "continents = country_counts['continent']\n", 607 | "continents" 608 | ] 609 | }, 610 | { 611 | "cell_type": "code", 612 | "execution_count": null, 613 | "metadata": {}, 614 | "outputs": [], 615 | "source": [ 616 | "n_continents = len(country_counts)\n", 617 | "x = range(n_continents)\n", 618 | "print(x)" 619 | ] 620 | }, 621 | { 622 | "cell_type": "code", 623 | "execution_count": null, 624 | "metadata": {}, 625 | "outputs": [], 626 | "source": [ 627 | "y = country_counts['n_countries']\n", 628 | "y" 629 | ] 630 | }, 631 | { 632 | "cell_type": "code", 633 | "execution_count": null, 634 | "metadata": {}, 635 | "outputs": [], 636 | "source": [ 637 | "plt.bar(x, y)\n", 638 | "\n", 639 | "plt.title('Number of Countries per Continent')\n", 640 | "plt.xticks(x, continents);" 641 | ] 642 | }, 643 | { 644 | "cell_type": "markdown", 645 | "metadata": {}, 646 | "source": [ 647 | "#### Pandas equivalent\n", 648 | "\n", 649 | "And here are three ways to use the `DataFrame.plot` Pandas method to get a nearly identical plot:" 650 | ] 651 | }, 652 | { 653 | "cell_type": "code", 654 | "execution_count": null, 655 | "metadata": {}, 656 | "outputs": [], 657 | "source": [ 658 | "# Option 1\n", 659 | "y.plot(kind='bar', title='Number of Countries per Continent')\n", 660 | "plt.xticks(x, continents);" 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "execution_count": null, 666 | "metadata": {}, 667 | "outputs": [], 668 | "source": [ 669 | "# Option 2\n", 670 | "ax = y.plot(kind='bar',\n", 671 | " title='Number of Countries per Continent',\n", 672 | " xticks=x)\n", 673 | "ax.set_xticklabels(continents);" 674 | ] 675 | }, 676 | { 677 | "cell_type": "code", 678 | "execution_count": null, 679 | "metadata": { 680 | "scrolled": true 681 | }, 682 | "outputs": [], 683 | "source": [ 684 | "# Option 3\n", 685 | "country_counts.plot(kind='bar',\n", 686 | " x='continent',\n", 687 | " y='n_countries', \n", 688 | " title='Number of Countries per Continent',\n", 689 | " legend=False);" 690 | ] 691 | }, 692 | { 693 | "cell_type": "markdown", 694 | "metadata": {}, 695 | "source": [ 696 | "***What happened in that second option?***\n", 697 | "\n", 698 | "The `DataFrame.plot` methods returns a Matplotlib Axes object\n", 699 | "(a handle for the axes we plotted on), which we can save to some variable (`ax`), and then call additional\n", 700 | "methods on to tweak the axes' characteristics!\n", 701 | "\n", 702 | "In fact, we would actually see that if we called `DataFrame.plot` without assigning its output to a variable, or silencing its output with the semicolon:" 703 | ] 704 | }, 705 | { 706 | "cell_type": "code", 707 | "execution_count": null, 708 | "metadata": {}, 709 | "outputs": [], 710 | "source": [ 711 | "y.plot(kind='bar')" 712 | ] 713 | }, 714 | { 715 | "cell_type": "markdown", 716 | "metadata": {}, 717 | "source": [ 718 | "At this point you may be thinking, \"why so many different approaches to the same thing?!\". It might be dizzying. \n", 719 | "\n", 720 | "But there is no need to remember the many different ways to do one thing! Just notice how tightly integrated into Pandas Matplotlib is, so that in the future you can search and use whichever approach works for you." 721 | ] 722 | }, 723 | { 724 | "cell_type": "markdown", 725 | "metadata": {}, 726 | "source": [ 727 | "#### Challenge Questions" 728 | ] 729 | }, 730 | { 731 | "cell_type": "code", 732 | "execution_count": null, 733 | "metadata": {}, 734 | "outputs": [], 735 | "source": [ 736 | "# Get the countries in Oceania in 2007\n", 737 | "gm_latest_oceania = gm_latest[gm_latest['continent'] == 'Oceania']\n", 738 | "gm_latest_oceania" 739 | ] 740 | }, 741 | { 742 | "cell_type": "markdown", 743 | "metadata": {}, 744 | "source": [ 745 | "3. Create a bar plot showing the per-capita GDP for all the countries in Oceania during 2007." 746 | ] 747 | }, 748 | { 749 | "cell_type": "code", 750 | "execution_count": null, 751 | "metadata": {}, 752 | "outputs": [], 753 | "source": [] 754 | }, 755 | { 756 | "cell_type": "markdown", 757 | "metadata": {}, 758 | "source": [ 759 | "4. **\\[OPTIONAL\\]**. The above bar plot shows the counts of countries in each continent. We might be interested in the proportion of countries that exist in each of the 5 continents. Do a web search for `plt.pie` and figure out how to make a pie plot that displays proportions of all countries contained in each of the 5 continents." 760 | ] 761 | }, 762 | { 763 | "cell_type": "code", 764 | "execution_count": null, 765 | "metadata": {}, 766 | "outputs": [], 767 | "source": [] 768 | }, 769 | { 770 | "cell_type": "markdown", 771 | "metadata": {}, 772 | "source": [ 773 | "### Boxplots\n", 774 | "\n", 775 | "Now that we know we've seen how GDP was distributed during 2007, and how many countries are in each continent, we might want to know how GDP is distributed within each continent. While we could plot 5 histograms, we can also take advantage of a useful type of plot for just this purpose, a **boxplot**.\n", 776 | "\n", 777 | "`plt.boxplot` creates just that, and can take a list of arrays, with each array representing a distribution to plot. Since the number of countries in each continent is different, we will create an array for each continent that contains the GDP values of all countries in each continent." 778 | ] 779 | }, 780 | { 781 | "cell_type": "code", 782 | "execution_count": null, 783 | "metadata": {}, 784 | "outputs": [], 785 | "source": [ 786 | "continent_gdp_latest = []\n", 787 | "for c in continents:\n", 788 | " gm_latest_cur_cont = gm_latest[gm_latest['continent'] == c]\n", 789 | " cur_gdp_vals = gm_latest_cur_cont['gdpPercap'].values\n", 790 | " continent_gdp_latest.append(cur_gdp_vals)" 791 | ] 792 | }, 793 | { 794 | "cell_type": "code", 795 | "execution_count": null, 796 | "metadata": {}, 797 | "outputs": [], 798 | "source": [ 799 | "continent_gdp_latest" 800 | ] 801 | }, 802 | { 803 | "cell_type": "markdown", 804 | "metadata": {}, 805 | "source": [ 806 | "In a boxplot a box is created for each array where the top and bottom lines of the box indicate the third and first quartiles, respectively. An orange bar in the middle indicates the median. \"Whiskers\" show the extent of the extreme values (in this case 1.5 times the interquartile range, which is the third minus the first quartile). \"Fliers\" or \"outliers\" are shown in black circles and are drawn for all values that are outside of the whiskers, or interquartile value here.\n", 807 | "\n", 808 | "Now we'll use this list of arrays to make a boxplot. We'll also update the xticks, title, axes labels." 809 | ] 810 | }, 811 | { 812 | "cell_type": "code", 813 | "execution_count": null, 814 | "metadata": {}, 815 | "outputs": [], 816 | "source": [ 817 | "plt.boxplot(continent_gdp_latest)\n", 818 | "plt.title('Per-Capita GDP Distributions Per Continent')\n", 819 | "plt.xlabel('Continents')\n", 820 | "plt.ylabel('Per-Capita GDP (International Dollars)')\n", 821 | "plt.xticks(range(1, len(continents) + 1), continents);" 822 | ] 823 | }, 824 | { 825 | "cell_type": "markdown", 826 | "metadata": {}, 827 | "source": [ 828 | "That's a useful figure, but there's a lot going on in such a small plot. Let's use `plt.figure(figsize=)`. to make the plot bigger. `figsize` takes a tuple of width and height, in inches. (Note that figure sizes change with changes to DPI.)" 829 | ] 830 | }, 831 | { 832 | "cell_type": "code", 833 | "execution_count": null, 834 | "metadata": {}, 835 | "outputs": [], 836 | "source": [ 837 | "plt.figure(figsize=(12, 8))\n", 838 | "plt.boxplot(continent_gdp_latest)\n", 839 | "plt.title('Per-Capita GDP Distributions Per Continent')\n", 840 | "plt.xlabel('Continents')\n", 841 | "plt.ylabel('Per-Capita GDP (International Dollars)')\n", 842 | "plt.xticks(range(1, len(continents) + 1), continents);" 843 | ] 844 | }, 845 | { 846 | "cell_type": "markdown", 847 | "metadata": {}, 848 | "source": [ 849 | "That's better!" 850 | ] 851 | }, 852 | { 853 | "cell_type": "markdown", 854 | "metadata": {}, 855 | "source": [ 856 | "#### Pandas equvialent\n", 857 | "\n", 858 | "Pandas also has a `DataFrame.boxplot` method!" 859 | ] 860 | }, 861 | { 862 | "cell_type": "code", 863 | "execution_count": null, 864 | "metadata": {}, 865 | "outputs": [], 866 | "source": [ 867 | "gm_latest.boxplot(column='gdpPercap', by='continent', grid=False, figsize=(10, 8));" 868 | ] 869 | }, 870 | { 871 | "cell_type": "markdown", 872 | "metadata": {}, 873 | "source": [ 874 | "#### Challenge Questions\n", 875 | "\n", 876 | "5. Knowing how to interpret your plots is almost as important as knowing how to make them! Looking at the above box plot of per-capita GDP for each continent, what information do you take away from it? Where do you think the U.S.A is represented in this plot? And how could you confirm that?" 877 | ] 878 | }, 879 | { 880 | "cell_type": "code", 881 | "execution_count": null, 882 | "metadata": {}, 883 | "outputs": [], 884 | "source": [] 885 | }, 886 | { 887 | "cell_type": "markdown", 888 | "metadata": {}, 889 | "source": [ 890 | "### Line Plots" 891 | ] 892 | }, 893 | { 894 | "cell_type": "markdown", 895 | "metadata": {}, 896 | "source": [ 897 | "Now let's say that we're interested in visualizing a single country's per-capita GDP, and seeing how it has changed over time. Let's look at Portugal's GDP per capita over time. To make things easier, we'll create a second `DataFrame` containing just data from Portugal." 898 | ] 899 | }, 900 | { 901 | "cell_type": "code", 902 | "execution_count": null, 903 | "metadata": {}, 904 | "outputs": [], 905 | "source": [ 906 | "portugal = gm[gm['country'] == 'Portugal']" 907 | ] 908 | }, 909 | { 910 | "cell_type": "code", 911 | "execution_count": null, 912 | "metadata": {}, 913 | "outputs": [], 914 | "source": [ 915 | "portugal.head()" 916 | ] 917 | }, 918 | { 919 | "cell_type": "markdown", 920 | "metadata": {}, 921 | "source": [ 922 | "While there are theoretically many ways we could plot these data, let's use what we learned about human perception from Cleveland and McGill to guide our choice of plots. We saw that \"position along a common scale\" was the most accurate perceptual task, and a **Line Plot** uses exactly that. In fact, line plots are one of the most commonly used plots for visualizing **time-series data** (data that changes as a function of time) because the data points are connected (unlike bar plots) allowing for easy perception of the trend across time. \n", 923 | "\n", 924 | "To make the line plot, we simply call the `plt.plot()` function. The first argument should contain a list-like sequence of $x$-axis values, and the second argument should contain a list-like sequence of the $y$-axis values. We'll use the year as the $x$-axis and per-capita GDP as the $y$-axis.\n", 925 | "\n", 926 | "**Note** that $x$ and $y$ must have the same dimensions-that is, be of the same length." 927 | ] 928 | }, 929 | { 930 | "cell_type": "code", 931 | "execution_count": null, 932 | "metadata": {}, 933 | "outputs": [], 934 | "source": [ 935 | "plt.plot(portugal['year'], portugal['gdpPercap'])\n", 936 | "plt.title('Per-capita GDP of Portugal')\n", 937 | "plt.xlabel('Time (Years)')\n", 938 | "plt.ylabel('Per-capita GPD (International Dollars)');" 939 | ] 940 | }, 941 | { 942 | "cell_type": "markdown", 943 | "metadata": {}, 944 | "source": [ 945 | "This plot clearly shows that Portugal's per-capita GDP has been increasing over time. Cool!\n", 946 | "\n", 947 | "What if we want to compare how Portugal's GDP changed relative to its neighbor's Spain? To do that we can get a second `DataFrame` for Spain and plot them together on the same plot. We'll also make the plot wide and short to better see time." 948 | ] 949 | }, 950 | { 951 | "cell_type": "code", 952 | "execution_count": null, 953 | "metadata": {}, 954 | "outputs": [], 955 | "source": [ 956 | "spain = gm[gm['country'] == 'Spain']" 957 | ] 958 | }, 959 | { 960 | "cell_type": "code", 961 | "execution_count": null, 962 | "metadata": {}, 963 | "outputs": [], 964 | "source": [ 965 | "plt.figure(figsize=(12, 5))\n", 966 | "plt.plot(spain['year'], spain['gdpPercap'])\n", 967 | "plt.plot(portugal['year'], portugal['gdpPercap'])\n", 968 | "plt.title('Per-capita GDP of Portugal & Spain')\n", 969 | "plt.xlabel('Time (Years)')\n", 970 | "plt.ylabel('Per-capita GPD (International Dollars)');" 971 | ] 972 | }, 973 | { 974 | "cell_type": "markdown", 975 | "metadata": {}, 976 | "source": [ 977 | "Ok, that's cool, but which line represents which country? To determine that we need a legend. `matplotlib` makes it easy to create a legend. First, we need to add the `label=` parameter to the `plt.plot()` functions, then call `plt.legend()`. Let's see it:" 978 | ] 979 | }, 980 | { 981 | "cell_type": "code", 982 | "execution_count": null, 983 | "metadata": {}, 984 | "outputs": [], 985 | "source": [ 986 | "plt.figure(figsize=(12,5))\n", 987 | "plt.plot(spain['year'], spain['gdpPercap'], label='Spain')\n", 988 | "plt.plot(portugal['year'], portugal['gdpPercap'], label='Portugal')\n", 989 | "plt.title('Per-capita GDP of Portugal & Spain')\n", 990 | "plt.xlabel('Time (Years)')\n", 991 | "plt.ylabel('Per-capita GPD (International Dollars)')\n", 992 | "plt.legend();" 993 | ] 994 | }, 995 | { 996 | "cell_type": "markdown", 997 | "metadata": {}, 998 | "source": [ 999 | "Much better! Now we can see that Spain's GDP has been consistently greater than Portugal's from 1950 until 2007." 1000 | ] 1001 | }, 1002 | { 1003 | "cell_type": "markdown", 1004 | "metadata": {}, 1005 | "source": [ 1006 | "#### Pandas equivalent\n", 1007 | "\n", 1008 | "Remember `DataFrame.plot`'s \"kind\" argument? Well it turns out that we can use that argument to create a variety of plot types!" 1009 | ] 1010 | }, 1011 | { 1012 | "cell_type": "code", 1013 | "execution_count": null, 1014 | "metadata": {}, 1015 | "outputs": [], 1016 | "source": [ 1017 | "help(gm.plot)" 1018 | ] 1019 | }, 1020 | { 1021 | "cell_type": "markdown", 1022 | "metadata": {}, 1023 | "source": [ 1024 | "Here's its line plot:" 1025 | ] 1026 | }, 1027 | { 1028 | "cell_type": "code", 1029 | "execution_count": null, 1030 | "metadata": {}, 1031 | "outputs": [], 1032 | "source": [ 1033 | "gm[gm.country.isin(['Spain', 'Portugal'])].pivot(index='year', \n", 1034 | " values='lifeExp', \n", 1035 | " columns='country').plot(figsize=(10, 8));" 1036 | ] 1037 | }, 1038 | { 1039 | "cell_type": "markdown", 1040 | "metadata": {}, 1041 | "source": [ 1042 | "#### Challenge Questions\n", 1043 | "\n", 1044 | "6. Create another line plot showing the life expectancy for Spain and Portugal across all the years in the dataset similar to the one above, but try to add some customizations (e.g., changing the font sizes, different line colors, etc.). You can use the `help()` function to see what kind of customizations are available." 1045 | ] 1046 | }, 1047 | { 1048 | "cell_type": "code", 1049 | "execution_count": null, 1050 | "metadata": {}, 1051 | "outputs": [], 1052 | "source": [] 1053 | }, 1054 | { 1055 | "cell_type": "markdown", 1056 | "metadata": {}, 1057 | "source": [ 1058 | "7. Does Spain or Portugal have a higher life expectancy across all the years? How does this relate to per-capita GDP? How might we look for a relationship?" 1059 | ] 1060 | }, 1061 | { 1062 | "cell_type": "code", 1063 | "execution_count": null, 1064 | "metadata": {}, 1065 | "outputs": [], 1066 | "source": [] 1067 | }, 1068 | { 1069 | "cell_type": "markdown", 1070 | "metadata": {}, 1071 | "source": [ 1072 | "### Scatter Plots" 1073 | ] 1074 | }, 1075 | { 1076 | "cell_type": "markdown", 1077 | "metadata": {}, 1078 | "source": [ 1079 | "Next, let's imagine that we're interested in looking for a relationship between two variables, where both variables can take the same value multiple times, unlike time-series data where the time variable is constantly increasing. **Scatter plots** are a powerful way to visualize the joint distribution of your data points across two variables. \n", 1080 | "\n", 1081 | "To illustrate this we'll use `plt.scatter` to visualize the relationship between per capita GDP (`gdpPercap` on the $x$-axis) and life expectancy (`lifeExp`on the $y$-axis) across all countries and all years. Specifying the `marker='.'` argument tells the plot to use small circles to indicate each data point. There are many other marker styles, see [here](https://matplotlib.org/stable/api/markers_api.html) for more." 1082 | ] 1083 | }, 1084 | { 1085 | "cell_type": "code", 1086 | "execution_count": null, 1087 | "metadata": {}, 1088 | "outputs": [], 1089 | "source": [ 1090 | "plt.scatter(gm['gdpPercap'], gm['lifeExp'], marker='.')\n", 1091 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 1092 | "plt.ylabel('Life Expectancy (years)');" 1093 | ] 1094 | }, 1095 | { 1096 | "cell_type": "markdown", 1097 | "metadata": {}, 1098 | "source": [ 1099 | "#### Pandas equivalent" 1100 | ] 1101 | }, 1102 | { 1103 | "cell_type": "code", 1104 | "execution_count": null, 1105 | "metadata": {}, 1106 | "outputs": [], 1107 | "source": [ 1108 | "gm.plot(x='gdpPercap', y='lifeExp', kind='scatter')\n", 1109 | "plt.xlabel('Per-Capita GDP (International Dollars)')\n", 1110 | "plt.ylabel('Life Expectancy (years)');" 1111 | ] 1112 | }, 1113 | { 1114 | "cell_type": "markdown", 1115 | "metadata": {}, 1116 | "source": [ 1117 | "Like with `plt.plot()`, the first argument in `plt.scatter()` corresponds to the $x$-axis and the second to the $y$-axis." 1118 | ] 1119 | }, 1120 | { 1121 | "cell_type": "markdown", 1122 | "metadata": {}, 1123 | "source": [ 1124 | "#### Transformations\n", 1125 | "\n", 1126 | "The above scatter plot has some really large GDP values out to the right of the plot. When dealing with data that have large outliers like this, plotting a transformation of the data can make it more interpretable. A standard transformation is to apply the `log` function, so let's try that here.\n", 1127 | "\n", 1128 | "**NOTE** Let's not forget to change the x-axis label to indicate the new units being displayed! " 1129 | ] 1130 | }, 1131 | { 1132 | "cell_type": "code", 1133 | "execution_count": null, 1134 | "metadata": {}, 1135 | "outputs": [], 1136 | "source": [ 1137 | "plt.scatter(np.log10(gm['gdpPercap']), gm['lifeExp'], marker='.')\n", 1138 | "plt.xlabel('Log Per-Capita GDP (International Dollars)')\n", 1139 | "plt.ylabel('Life Expectancy (years)');" 1140 | ] 1141 | }, 1142 | { 1143 | "cell_type": "markdown", 1144 | "metadata": {}, 1145 | "source": [ 1146 | "That looks much better. We can now see there is somewhat of a linear relationship between the log of GDP and life expectancy. Interesting!" 1147 | ] 1148 | }, 1149 | { 1150 | "cell_type": "markdown", 1151 | "metadata": {}, 1152 | "source": [ 1153 | "#### Transparency\n", 1154 | "\n", 1155 | "This plot looks good, but could be better, especially since there are so many points and they overlap. To fix that we can change the transparency, or opacity, of the face and edges of the markers using the `alpha` parameter. This is a value from `0`-`1`, where `0` is completely transparent (e.g. it's not displayed) to `1` being completely opaque (which is the default seen in the previous plot).\n", 1156 | "\n", 1157 | "And while we're at it we'll change the fill color with the `facecolor` parameter, and the border color of each marker with the `edgecolor` parameter using one of:\n", 1158 | "\n", 1159 | "* single letters representing built-in colors (e.g., `b` for blue)\n", 1160 | "* html hex strings\n", 1161 | "* html color names\n", 1162 | "* RGB tuples (with each element between 0 and 1)\n", 1163 | "* string encoded floating point values between 0 and 1 (for gray shades)\n", 1164 | "\n", 1165 | "For *no* color, use `'None'`. For more information on colors in `Matplotlib` see [the documentation](https://matplotlib.org/stable/api/colors_api.html).\n", 1166 | "\n", 1167 | "A great place to find information on color palettes is [ColorBrewer](http://colorbrewer2.org/). Matt Davis has created a great Python package called [Palettable](https://jiffyclub.github.io/palettable/) that gives you access to the ColorBrewer, Cubehelix, Tableau, and Wes Anderson palettes." 1168 | ] 1169 | }, 1170 | { 1171 | "cell_type": "code", 1172 | "execution_count": null, 1173 | "metadata": {}, 1174 | "outputs": [], 1175 | "source": [ 1176 | "plt.scatter(np.log10(gm['gdpPercap']), \n", 1177 | " gm['lifeExp'], \n", 1178 | " marker='o',\n", 1179 | " alpha=0.25,\n", 1180 | " facecolor='SteelBlue',\n", 1181 | " edgecolor='None')\n", 1182 | "plt.xlabel('Log Per-Capita GDP (International Dollars)')\n", 1183 | "plt.ylabel('Life Expectancy (years)');" 1184 | ] 1185 | }, 1186 | { 1187 | "cell_type": "markdown", 1188 | "metadata": {}, 1189 | "source": [ 1190 | "Now that we've seen that there exists a relationship between GDP and life expectancy at the global scale and across the last 50 years, let's see if we can use similar scatter plots to break that relationship down as a function of both time (year) and location (continent). \n", 1191 | "\n", 1192 | "To do that we'll introduce two new techniques, the use of color and `subplots`." 1193 | ] 1194 | }, 1195 | { 1196 | "cell_type": "markdown", 1197 | "metadata": {}, 1198 | "source": [ 1199 | "#### Color" 1200 | ] 1201 | }, 1202 | { 1203 | "cell_type": "markdown", 1204 | "metadata": {}, 1205 | "source": [ 1206 | "Although color was the worst of the 6 perceptual tasks found by Cleveland and McGill it can still be a useful way to add even more information to the figure. \n", 1207 | "\n", 1208 | "Within a scatter plot, each data point may be assigned a different color depending on it's value in a third variable. To do so, we provide two additional keyword arguments to the `plt.scatter` method. \n", 1209 | "\n", 1210 | "The first is `c=`, where `` is a list-like sequence of values that is the same length as the data being plotted. The numbers will be normalized from 0-1, so any numbers will do. The second is `cmap=`, where `` is the name of `matplotlib` colormap, see [here](https://matplotlib.org/stable/tutorials/colors/colormaps.html) for possibilities.\n", 1211 | "\n", 1212 | "We'll make the same exact scatter plot as we just did, but add color to represent the year the data comes from. We'll use the `hot` colormap which goes from black->red->orange->yellow->white." 1213 | ] 1214 | }, 1215 | { 1216 | "cell_type": "code", 1217 | "execution_count": null, 1218 | "metadata": {}, 1219 | "outputs": [], 1220 | "source": [ 1221 | "plt.scatter(np.log10(gm['gdpPercap']), gm['lifeExp'], marker='.', c=gm['year'], cmap='hot')\n", 1222 | "plt.xlabel('Log Per-Capita GDP (International Dollars)')\n", 1223 | "plt.ylabel('Life Expectancy (Years)');" 1224 | ] 1225 | }, 1226 | { 1227 | "cell_type": "markdown", 1228 | "metadata": {}, 1229 | "source": [ 1230 | "While we can see there is some sort of trend dependent on color, we don't know what the color values mean. \n", 1231 | "\n", 1232 | "We can use `plt.colorbar()` to add a colorbar which will let us interpret the colors. By adding `.set_label()` to it we can set a textual label describing what the values in the colorbar represent.\n", 1233 | "\n", 1234 | "We'll also increase the figure size, and the font size used in the title, xlabel and ylabel using the `fontsize=16` parameter. We'll also use a form of LaTeX called MathJax to write a subscript 10 underneath the word Log, like this: $\\log_{10}$." 1235 | ] 1236 | }, 1237 | { 1238 | "cell_type": "code", 1239 | "execution_count": null, 1240 | "metadata": {}, 1241 | "outputs": [], 1242 | "source": [ 1243 | "plt.figure(figsize=(10, 8))\n", 1244 | "plt.scatter(np.log10(gm['gdpPercap']), gm['lifeExp'], marker='.', c=gm['year'], cmap='hot')\n", 1245 | "plt.xlabel('$Log_{10}$ Per-Capita GDP (International Dollars)', fontsize=16)\n", 1246 | "plt.ylabel('Life Expectancy (Years)', fontsize=16)\n", 1247 | "plt.colorbar().set_label('Year', fontsize=16);" 1248 | ] 1249 | }, 1250 | { 1251 | "cell_type": "markdown", 1252 | "metadata": {}, 1253 | "source": [ 1254 | "Ok, now we can see that as time has increased from black in 1950 to yellow in 2000 average life expectancy has also increased. Nice! \n", 1255 | "\n", 1256 | "\n", 1257 | "Now let's use `subplots` to break this down even further and see if this trend holds across all continents." 1258 | ] 1259 | }, 1260 | { 1261 | "cell_type": "markdown", 1262 | "metadata": {}, 1263 | "source": [ 1264 | "#### `plt.subplot`\n", 1265 | "\n", 1266 | "Subplots allow you to draw multiple plots within a single figure. To do so, you use `plt.subplot(, , )` where the number of rows and columns you want in the figure are specified as the first two parameters, respectively. The `` tells subplot which subplot subsequent calls to `plt` will draw in. It starts at `1` for the top left subplot, and increases across rows, and then down columns. \n", 1267 | "\n", 1268 | "**NOTE** `plt.subplot()` uses a 1-based index (not 0-based like Python) to emulate the behavior of the Matlab version of this function. This can cause confusion!!\n", 1269 | "\n", 1270 | "Let's look at a simple example plotting Spain and Portugal's GDP on separate plots next to each other in the same row." 1271 | ] 1272 | }, 1273 | { 1274 | "cell_type": "code", 1275 | "execution_count": null, 1276 | "metadata": {}, 1277 | "outputs": [], 1278 | "source": [ 1279 | "plt.figure(figsize=(15, 5))\n", 1280 | "plt.subplot(1, 2, 1)\n", 1281 | "plt.plot(spain['year'], spain['gdpPercap'], label='Spain', color='blue')\n", 1282 | "plt.title('Spain')\n", 1283 | "plt.xlabel('Time (Years)')\n", 1284 | "plt.ylabel('Per-capita GPD (International Dollars)')\n", 1285 | "plt.legend();\n", 1286 | "\n", 1287 | "plt.subplot(1, 2, 2)\n", 1288 | "plt.plot(portugal['year'], portugal['gdpPercap'], label='Portugal', color='red')\n", 1289 | "plt.title('Portugal')\n", 1290 | "plt.xlabel('Time (Years)')\n", 1291 | "plt.ylabel('Per-capita GPD (International Dollars)')\n", 1292 | "plt.legend();" 1293 | ] 1294 | }, 1295 | { 1296 | "cell_type": "markdown", 1297 | "metadata": {}, 1298 | "source": [ 1299 | "That looks pretty good, but if a careful observer would notice that these two plots are not on the same y-axis scales, and so cannot be easily compared at a glance. That is because matplotlib will automatically determine the min and max values for the y-axis based on the data itself. This results in a plot that is using as much of the \"screen real-estate\" as possible, and is usually what you want, but not always.\n", 1300 | "\n", 1301 | "To set the y-axis values explicitly, we'll use the `vmin` and `vmax` option parameters. Let's see it:" 1302 | ] 1303 | }, 1304 | { 1305 | "cell_type": "code", 1306 | "execution_count": null, 1307 | "metadata": {}, 1308 | "outputs": [], 1309 | "source": [ 1310 | "plt.figure(figsize=(15, 5))\n", 1311 | "plt.subplot(1, 2, 1)\n", 1312 | "plt.plot(spain['year'], spain['gdpPercap'], label='Spain', color='blue')\n", 1313 | "plt.title('Spain')\n", 1314 | "plt.xlabel('Time (Years)')\n", 1315 | "plt.ylabel('Per-capita GPD (International Dollars)')\n", 1316 | "plt.ylim(2500, 30000)\n", 1317 | "plt.legend();\n", 1318 | "\n", 1319 | "plt.subplot(1, 2, 2)\n", 1320 | "plt.plot(portugal['year'], portugal['gdpPercap'], label='Portugal', color='red')\n", 1321 | "plt.title('Portugal')\n", 1322 | "plt.xlabel('Time (Years)')\n", 1323 | "plt.ylabel('Per-capita GPD (International Dollars)')\n", 1324 | "plt.ylim(2500, 30000)\n", 1325 | "plt.legend();" 1326 | ] 1327 | }, 1328 | { 1329 | "cell_type": "markdown", 1330 | "metadata": {}, 1331 | "source": [ 1332 | "Now we can see that Spain's per-capita GDP is actually much higher than Portugal's, which we couldn't easily tell before.\n", 1333 | "\n", 1334 | "Now let's use subplots to make scatter plots for each continent separately. Since we have data on 5 continents, we'll make a figure with 6 subplots, 3 rows and 2 columns.\n", 1335 | "\n", 1336 | "To do so we'll iterate (loop) over each continent and get a `DataFrame` that contains only the rows for countries in that continent. Then we'll set the subplot and create a scatter plot using that new `DataFrame`. Here's how it looks:" 1337 | ] 1338 | }, 1339 | { 1340 | "cell_type": "code", 1341 | "execution_count": null, 1342 | "metadata": {}, 1343 | "outputs": [], 1344 | "source": [ 1345 | "# NOTE: This MUST come first, one of the few things in plt where order matters\n", 1346 | "plt.figure(figsize=(20, 20))\n", 1347 | "\n", 1348 | "for i,continent in enumerate(continents):\n", 1349 | " # Get a dataframe with just countries in the current continent\n", 1350 | " cur_continent_df = gm[gm['continent'] == continent]\n", 1351 | "\n", 1352 | " # Set the current subplot\n", 1353 | " plt.subplot(3, 2, i+1)\n", 1354 | " \n", 1355 | " # make the current scatter plot \n", 1356 | " plt.scatter(np.log10(cur_continent_df['gdpPercap']), \n", 1357 | " cur_continent_df['lifeExp'], \n", 1358 | " marker='.', \n", 1359 | " c=cur_continent_df['year'], \n", 1360 | " cmap='hot')\n", 1361 | " plt.xlabel('$Log_{10}$ Per-Capita GDP (International Dollars)', fontsize=14)\n", 1362 | " plt.ylabel('Life Expectancy (Years)', fontsize=14)\n", 1363 | " plt.title(continent, fontsize=14)\n", 1364 | " plt.ylim(25, 85)\n", 1365 | " plt.colorbar().set_label('Year', fontsize=14);" 1366 | ] 1367 | }, 1368 | { 1369 | "cell_type": "markdown", 1370 | "metadata": {}, 1371 | "source": [ 1372 | "#### Challenge Questions\n", 1373 | "\n", 1374 | "8. We've seen that life expectancy and per-capita GDP have a positive relationship. What about the relationship between population and per-capita GDP, is there one? Create a scatter plot that compares the two across all countries in 2007. " 1375 | ] 1376 | }, 1377 | { 1378 | "cell_type": "code", 1379 | "execution_count": null, 1380 | "metadata": {}, 1381 | "outputs": [], 1382 | "source": [] 1383 | }, 1384 | { 1385 | "cell_type": "markdown", 1386 | "metadata": {}, 1387 | "source": [ 1388 | "9. Is that relationship between population and per-capita GDP different for the first year we have data in the dataset? Plot both first and latest years scatter next to each other in the same figure but different subplots. What can you say about any outliers you see?\n", 1389 | "\n", 1390 | "(*HINT*: First you need to extract another `DataFrame` containing the data from the first year)." 1391 | ] 1392 | }, 1393 | { 1394 | "cell_type": "code", 1395 | "execution_count": null, 1396 | "metadata": {}, 1397 | "outputs": [], 1398 | "source": [] 1399 | }, 1400 | { 1401 | "cell_type": "markdown", 1402 | "metadata": {}, 1403 | "source": [ 1404 | "#### Pandas approach\n", 1405 | "\n", 1406 | "Here are a pair of plots related to (but not directly answering) the above questions, using Pandas methods again." 1407 | ] 1408 | }, 1409 | { 1410 | "cell_type": "code", 1411 | "execution_count": null, 1412 | "metadata": {}, 1413 | "outputs": [], 1414 | "source": [ 1415 | "min_yr = gm.year.min()\n", 1416 | "gm_first_yr = gm[gm.year == min_yr]\n", 1417 | "gm.plot(x = 'gdpPercap', y='pop', kind='scatter', figsize=(10, 8))\n", 1418 | "plt.xlabel('GDP per capita')\n", 1419 | "plt.ylabel('Population')\n", 1420 | "plt.title('Population vs. GPD per capita, first year');" 1421 | ] 1422 | }, 1423 | { 1424 | "cell_type": "code", 1425 | "execution_count": null, 1426 | "metadata": {}, 1427 | "outputs": [], 1428 | "source": [ 1429 | "gm.plot(x = 'gdpPercap', y='pop', c='year', cmap='spring', kind='scatter', figsize=(10, 8))\n", 1430 | "plt.xlabel('GDP per capita')\n", 1431 | "plt.ylabel('Population')\n", 1432 | "plt.title('Population vs. GPD per capita, across years');" 1433 | ] 1434 | }, 1435 | { 1436 | "cell_type": "markdown", 1437 | "metadata": {}, 1438 | "source": [ 1439 | "10. **\\[OPTIONAL\\]** Above we created a scatter plot between life expectancy and per-capita GDP colored by year. That coloring was done in a continuous way. What if we wanted to color it by decade instead, making a discrete coloring? Run the code cell below to create a new variable called `decades`. Then create another scatter plot of life expectancy vs per-capita GDP assigning the color strings in `hexsix` to data points from each of the six decades in the dataset. " 1440 | ] 1441 | }, 1442 | { 1443 | "cell_type": "code", 1444 | "execution_count": null, 1445 | "metadata": {}, 1446 | "outputs": [], 1447 | "source": [ 1448 | "hexsix = np.array(['#ffffcc', '#d9f0a3', '#addd8e', '#78c679', '#31a354', '#006837'])\n", 1449 | "gm['decade'] = (gm['year'] / 10).astype(int) * 10\n", 1450 | "decades = gm['decade'].unique()\n", 1451 | "decades" 1452 | ] 1453 | }, 1454 | { 1455 | "cell_type": "code", 1456 | "execution_count": null, 1457 | "metadata": {}, 1458 | "outputs": [], 1459 | "source": [] 1460 | }, 1461 | { 1462 | "cell_type": "markdown", 1463 | "metadata": {}, 1464 | "source": [ 1465 | "## Plot Customization" 1466 | ] 1467 | }, 1468 | { 1469 | "cell_type": "markdown", 1470 | "metadata": {}, 1471 | "source": [ 1472 | "The `matplotlib` defaults aren't the best. We've already changed several properties of the figures we've made, including the color and opacity of scatter plots, and font sizes for the title and axis label text. While this is useful, it can become tedious to include many customization parameters in every plot we make. We can, however, customize almost any property for all plots using the `matplotlibrc` configuration file. This file allows you to specify new default values for `matplotlib` properties, which are called \"rc settings\" or \"rc parameters\". These settings are then loaded every time you use `matplotlib`.\n", 1473 | "\n", 1474 | "The `matplotlibrc` file is typically found in the `.../site-packages/matplotlib/mpl-data` directory. Here is an example of a full path: `/usr/local/lib/python2.7/site-packages/matplotlib/mpl-data`. The full path on your computer will depend on where *your* Python is installed.\n" 1475 | ] 1476 | }, 1477 | { 1478 | "cell_type": "markdown", 1479 | "metadata": {}, 1480 | "source": [ 1481 | "Before setting these new rc settings manually, let's create a plot using the default rc settings, so we can see how they change the look of the plot. \n", 1482 | "\n", 1483 | "We'll plot the average per-capita GDP across time for each continent separately. To do this we'll use `groupby` again, this time grouping by continent and year, and then taking the mean over GDP." 1484 | ] 1485 | }, 1486 | { 1487 | "cell_type": "code", 1488 | "execution_count": null, 1489 | "metadata": {}, 1490 | "outputs": [], 1491 | "source": [ 1492 | "per_continent_mean_gdp = gm.groupby(['continent', 'year'], as_index=False)['gdpPercap'].mean()" 1493 | ] 1494 | }, 1495 | { 1496 | "cell_type": "code", 1497 | "execution_count": null, 1498 | "metadata": {}, 1499 | "outputs": [], 1500 | "source": [ 1501 | "plt.figure(figsize=(10, 8))\n", 1502 | "\n", 1503 | "for continent in continents:\n", 1504 | " cur_continent_df = per_continent_mean_gdp[per_continent_mean_gdp['continent'] == continent]\n", 1505 | " plt.plot(cur_continent_df['year'], \n", 1506 | " cur_continent_df['gdpPercap'], \n", 1507 | " alpha=0.75, \n", 1508 | " label=continent)\n", 1509 | "\n", 1510 | "plt.title('Continent-Level Average GDP Per Capita, by Year')\n", 1511 | "plt.xlabel('Year')\n", 1512 | "plt.ylabel('Average GDP Per Capita')\n", 1513 | "plt.legend(loc='upper left');" 1514 | ] 1515 | }, 1516 | { 1517 | "cell_type": "markdown", 1518 | "metadata": {}, 1519 | "source": [ 1520 | "Ok, that's a decent looking plot, but it can be better! Let's change the default rc settings. Instead of modifying the `matplotlibrc` file directly, we'll change some default rc settings directly using Python code. Changing the rc settings in code *does not* modify your `matplotlibrc` file, and it only changes the settings for the current Python session. \n", 1521 | "\n", 1522 | "Below is a dictionary containing some rc parameters whose values we're going to modify. The keys of the dictionary are the rc parameter names, and the values are the new defaults that we're setting. \n", 1523 | "\n", 1524 | "These parameter values come from Cameron Davidson-Pilon's [Bayesian Methods for Hackers](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/styles/matplotlibrc#L240) colors.\n", 1525 | "\n", 1526 | "Let's have a look..." 1527 | ] 1528 | }, 1529 | { 1530 | "cell_type": "code", 1531 | "execution_count": null, 1532 | "metadata": {}, 1533 | "outputs": [], 1534 | "source": [ 1535 | "params = {'figure.facecolor' : 'white',\n", 1536 | " 'axes.facecolor' : 'white',\n", 1537 | " \n", 1538 | " 'axes.titlesize' : 'x-large',\n", 1539 | " 'axes.axisbelow' : True,\n", 1540 | " \n", 1541 | " 'axes.edgecolor' : 'DimGray',\n", 1542 | " 'axes.linewidth' : 0.5,\n", 1543 | " \n", 1544 | " 'axes.labelsize' : 'large',\n", 1545 | " 'axes.labelcolor' : '#4A4A4A',\n", 1546 | " \n", 1547 | " 'axes.grid' : True,\n", 1548 | " 'grid.linestyle' : ':',\n", 1549 | " 'grid.color' : 'DimGray',\n", 1550 | " 'grid.alpha' : 0.5,\n", 1551 | " \n", 1552 | " 'xtick.color' : '#4A4A4A',\n", 1553 | " 'xtick.major.size' : 0,\n", 1554 | " 'xtick.minor.size' : 0,\n", 1555 | " 'xtick.labelsize' : 'medium',\n", 1556 | " \n", 1557 | " 'ytick.color' : '#4A4A4A',\n", 1558 | " 'ytick.major.size' : 0,\n", 1559 | " 'ytick.minor.size' : 0,\n", 1560 | " 'ytick.labelsize' : 'medium',\n", 1561 | " \n", 1562 | " 'text.color' : '#4A4A4A',\n", 1563 | " \n", 1564 | " 'legend.fancybox' : False,\n", 1565 | " 'legend.frameon' : False,\n", 1566 | " 'legend.fontsize' : 'large'}" 1567 | ] 1568 | }, 1569 | { 1570 | "cell_type": "markdown", 1571 | "metadata": {}, 1572 | "source": [ 1573 | "We don't have the time to go through each setting separately, so we'll just see the overall before and after effect. The names are somewhat intuitive however, but more information on all the settings can be found in the [documentation](https://matplotlib.org/stable/tutorials/introductory/customizing.html). You can also get a complete list of all the possible parameters by printing `mpl.rcParams`.\n", 1574 | "\n", 1575 | "The rc settings are stored in a dictionary-like variable called `matplotlib.rcParams`. Because we imported `matplotlib` using `import matplotlib as mpl`, we'll need to use `mpl.rcParams` instead. \n", 1576 | "\n", 1577 | "To update the default settings we simply iterate over all of the rcsettings in the dictionary we just created, and update `plt.rcParams` with each key/value pair, like this." 1578 | ] 1579 | }, 1580 | { 1581 | "cell_type": "code", 1582 | "execution_count": null, 1583 | "metadata": {}, 1584 | "outputs": [], 1585 | "source": [ 1586 | "for (k, v) in params.items():\n", 1587 | " plt.rcParams[k] = v" 1588 | ] 1589 | }, 1590 | { 1591 | "cell_type": "markdown", 1592 | "metadata": {}, 1593 | "source": [ 1594 | "Now let's recreate the same exact time-series plot of the average GDP per continent. The code here is *EXACTLY* the same as in several cells above. What makes the plots look different is the setting of the default rc parameters we just did." 1595 | ] 1596 | }, 1597 | { 1598 | "cell_type": "code", 1599 | "execution_count": null, 1600 | "metadata": {}, 1601 | "outputs": [], 1602 | "source": [ 1603 | "plt.figure(figsize=(10, 8))\n", 1604 | "\n", 1605 | "for continent in continents:\n", 1606 | " cur_continent_df = per_continent_mean_gdp[per_continent_mean_gdp['continent'] == continent]\n", 1607 | " plt.plot(cur_continent_df['year'], \n", 1608 | " cur_continent_df['gdpPercap'], \n", 1609 | " alpha=0.75, \n", 1610 | " label=continent)\n", 1611 | "\n", 1612 | "plt.title('Continent-Level Average GDP Per Capita, by Year')\n", 1613 | "plt.xlabel('Year')\n", 1614 | "plt.ylabel('Average GDP Per Capita')\n", 1615 | "plt.legend(loc='upper left');" 1616 | ] 1617 | }, 1618 | { 1619 | "cell_type": "markdown", 1620 | "metadata": {}, 1621 | "source": [ 1622 | "What's changed? Do you like this look better?" 1623 | ] 1624 | }, 1625 | { 1626 | "cell_type": "markdown", 1627 | "metadata": {}, 1628 | "source": [ 1629 | "#### Style Sheets\n", 1630 | "\n", 1631 | "Style sheets are built-in collections of rc parameters that allow for a quick and easy way to get nice looking plots in a particular style. To use a style sheet you simply call the `plt.style.use()` function and give it the name of the style sheet you want to use. Let's try to use the \"Five Thirty Eight\" style sheet, the name of which you might recognize as Nate Silver's website, of New York Times data visualization fame.\n", 1632 | "\n", 1633 | "For more on style sheets print all available style sheets using `plt.style.available`, or see the ([documentation](https://matplotlib.org/stable/tutorials/introductory/customizing.html))." 1634 | ] 1635 | }, 1636 | { 1637 | "cell_type": "code", 1638 | "execution_count": null, 1639 | "metadata": {}, 1640 | "outputs": [], 1641 | "source": [ 1642 | "plt.style.use('fivethirtyeight')" 1643 | ] 1644 | }, 1645 | { 1646 | "cell_type": "markdown", 1647 | "metadata": {}, 1648 | "source": [ 1649 | "Now we'll use the same code again, and see how it has changed!" 1650 | ] 1651 | }, 1652 | { 1653 | "cell_type": "code", 1654 | "execution_count": null, 1655 | "metadata": {}, 1656 | "outputs": [], 1657 | "source": [ 1658 | "plt.figure(figsize=(10, 8))\n", 1659 | "\n", 1660 | "for continent in continents:\n", 1661 | " cur_continent_df = per_continent_mean_gdp[per_continent_mean_gdp['continent'] == continent]\n", 1662 | " plt.plot(cur_continent_df['year'], \n", 1663 | " cur_continent_df['gdpPercap'], \n", 1664 | " alpha=0.75, \n", 1665 | " label=continent)\n", 1666 | "\n", 1667 | "plt.title('Continent-Level Average GDP Per Capita, by Year')\n", 1668 | "plt.xlabel('Year')\n", 1669 | "plt.ylabel('Average GDP Per Capita')\n", 1670 | "plt.legend(loc='upper left');" 1671 | ] 1672 | }, 1673 | { 1674 | "cell_type": "markdown", 1675 | "metadata": {}, 1676 | "source": [ 1677 | "## Seaborn" 1678 | ] 1679 | }, 1680 | { 1681 | "cell_type": "markdown", 1682 | "metadata": {}, 1683 | "source": [ 1684 | "\"`Seaborn` is a Python visualization library based on `Matplotlib`. It provides a high-level interface for drawing attractive statistical graphics.\"\n", 1685 | "\n", 1686 | "Let's import it and give it the alias `sns`, which is done by convention." 1687 | ] 1688 | }, 1689 | { 1690 | "cell_type": "code", 1691 | "execution_count": null, 1692 | "metadata": {}, 1693 | "outputs": [], 1694 | "source": [ 1695 | "import seaborn as sns\n", 1696 | "sns.set(rc={'axes.facecolor' : '#EEEEEE'})" 1697 | ] 1698 | }, 1699 | { 1700 | "cell_type": "markdown", 1701 | "metadata": {}, 1702 | "source": [ 1703 | "The `sns.set()` function allows us to change some of the `rcParams`. Here, we're changing the plot's face color.\n", 1704 | "\n", 1705 | "`seaborn` has the capacity to create a large number of informative, beautiful plots very easily. Here we'll review several types, but please visit their [gallery](https://seaborn.pydata.org/examples/index.html) for a more complete picture of all that you can do with `seaborn`." 1706 | ] 1707 | }, 1708 | { 1709 | "cell_type": "markdown", 1710 | "metadata": {}, 1711 | "source": [ 1712 | "### Boxplots Revisited\n", 1713 | "We previously looked at boxplots in `matplotlib`. Let's now use `seaborn` to look at the distributions of life expectancies separately for each continent. \n", 1714 | "\n", 1715 | "`Seaborn` includes native support for `pandas` data structures. To use it we specify the `DataFrame` we want to take the data from in the `data` parameter. We then specify which column names (or variables) from that `DataFrame` to use for in `x` and `y`. `x` specifies the variable to groupby, and `y` specifies the variable whose distribution should be plotted.\n", 1716 | "\n", 1717 | "We'll plot the continents in alphabetical order by specifying the `order=` parameter, make the box face colors all white using `color='white'`, and disable drawing of the fliers (or outliers) using `fliersize=0`.\n", 1718 | "\n", 1719 | "In addition to the boxplot, we'll plot a **stripplot**, which overlays a scatter plot of all the data points over each box. In combination, they're quite useful for understanding distributions. This takes many of the same parameters as the boxplot did, with the exception of `jitter=True` which causes the scatter markers to be slightly jittered horizontally. " 1720 | ] 1721 | }, 1722 | { 1723 | "cell_type": "code", 1724 | "execution_count": null, 1725 | "metadata": {}, 1726 | "outputs": [], 1727 | "source": [ 1728 | "plt.figure(figsize=(10, 8))\n", 1729 | "\n", 1730 | "sns.boxplot(x=\"continent\", y=\"lifeExp\", data=gm,\n", 1731 | " order=np.sort(gm.continent.unique()),\n", 1732 | " color='white', fliersize=0)\n", 1733 | "sns.stripplot(x=\"continent\", y=\"lifeExp\", data=gm,\n", 1734 | " order=np.sort(gm.continent.unique()),\n", 1735 | " alpha=0.25, size=5, jitter=True,\n", 1736 | " color='Black', edgecolor='Black')\n", 1737 | "\n", 1738 | "plt.title(\"Life Expectancy by Continent\")\n", 1739 | "plt.xlabel('Continent')\n", 1740 | "plt.ylabel('Life Expectancy');" 1741 | ] 1742 | }, 1743 | { 1744 | "cell_type": "markdown", 1745 | "metadata": {}, 1746 | "source": [ 1747 | "With just a few lines of code we have a very nice looking plot using `seaborn`. It's possible to create a stripplot using `Matplotlib`, but it's not as easy as it is with `Seaborn`." 1748 | ] 1749 | }, 1750 | { 1751 | "cell_type": "markdown", 1752 | "metadata": {}, 1753 | "source": [ 1754 | "### Heatmaps \n", 1755 | "`Seaborn` can be used to create Heatmaps which are helpful visualizations when we would like to plot three variables, one continuous and two factors in which a color scale is created to highlight the magnitude of the continuous variable.\n", 1756 | "\n", 1757 | "We will revisit our `per_continent_mean_gdp` dataset that outlines the average per-capita GDP across time for each continent to create our heatmap. " 1758 | ] 1759 | }, 1760 | { 1761 | "cell_type": "code", 1762 | "execution_count": null, 1763 | "metadata": {}, 1764 | "outputs": [], 1765 | "source": [ 1766 | "heatmap = per_continent_mean_gdp.pivot(index=\"year\", \n", 1767 | " columns=\"continent\", \n", 1768 | " values=\"gdpPercap\")\n", 1769 | "heatmap = heatmap.sort_index(ascending=False)\n", 1770 | "heatmap_graph = sns.heatmap(heatmap,\n", 1771 | " cbar_kws = {'label' : \"gdpPercap\"})\n", 1772 | "\n", 1773 | "plt.title(\"Average per-capita GDP across time for each continent\");" 1774 | ] 1775 | }, 1776 | { 1777 | "cell_type": "markdown", 1778 | "metadata": {}, 1779 | "source": [ 1780 | "### Regression Plots\n", 1781 | "\n", 1782 | "While `seaborn` provides easy ways to make nice-looking plots, it is ultimately a package built for statistical data visualization. It includes many useful built-in plots, such as the following **regression plot**. Here all the data values are plotted using a scatter plot, and a regression line is fit, and plotted, over that data. " 1783 | ] 1784 | }, 1785 | { 1786 | "cell_type": "code", 1787 | "execution_count": null, 1788 | "metadata": {}, 1789 | "outputs": [], 1790 | "source": [ 1791 | "sns.regplot(x='year', y='lifeExp', data=gm, color='teal')\n", 1792 | "\n", 1793 | "plt.title('Distribution of Life Expectancy, by Year')\n", 1794 | "plt.xlabel('Year')\n", 1795 | "plt.ylabel('Life Expectancy');" 1796 | ] 1797 | }, 1798 | { 1799 | "cell_type": "markdown", 1800 | "metadata": {}, 1801 | "source": [ 1802 | "### Kernel Density Plots\n", 1803 | "\n", 1804 | "We learned earlier that histograms can be used to visualize the discretized distribution of a variable. We must specify the number of bins in a histogram and as a result the shape of the distribution can change wildly depending on that somewhat arbitrary choice.\n", 1805 | "\n", 1806 | "A better way to plot a distribution is to estimate it's kernel density and plot it using `sns.kdeplot()`. Let's plot the kernel density for per-capita GDP in 2007 as we did earlier using a histogram. In fact, let's plot the two side by side using subplots." 1807 | ] 1808 | }, 1809 | { 1810 | "cell_type": "code", 1811 | "execution_count": null, 1812 | "metadata": {}, 1813 | "outputs": [], 1814 | "source": [ 1815 | "plt.figure(figsize=(15, 5))\n", 1816 | "\n", 1817 | "plt.subplot(1, 2, 1)\n", 1818 | "plt.hist(gm_latest['gdpPercap'])\n", 1819 | "plt.xlabel('gdpPercap')\n", 1820 | "plt.ylabel(\"# of Countries\")\n", 1821 | "plt.title('Histogram of 2007 GDP')\n", 1822 | "\n", 1823 | "plt.subplot(1, 2, 2)\n", 1824 | "sns.kdeplot(gm_latest['gdpPercap'], shade=True)\n", 1825 | "plt.title('Kernel Density of 2007 GDP');" 1826 | ] 1827 | }, 1828 | { 1829 | "cell_type": "markdown", 1830 | "metadata": {}, 1831 | "source": [ 1832 | "### Joint Distribution Plots\n", 1833 | "\n", 1834 | "We've already used scatter plots to visualize the relationship between two variables. It is sometimes useful to not only see the relationship between the two variables, but to visualize each variables respective distribution. The `sns.jointplot` function in `seaborn` let's you do just that.\n", 1835 | "\n", 1836 | "Let's compare the log of per-capita GDP and life expectancy in a joint distribution plot." 1837 | ] 1838 | }, 1839 | { 1840 | "cell_type": "code", 1841 | "execution_count": null, 1842 | "metadata": {}, 1843 | "outputs": [], 1844 | "source": [ 1845 | "sns.jointplot(x=np.log10(gm['gdpPercap']), y=gm['lifeExp'], color=\"#348ABD\", alpha=0.5);" 1846 | ] 1847 | }, 1848 | { 1849 | "cell_type": "markdown", 1850 | "metadata": {}, 1851 | "source": [ 1852 | "### Caveats\n", 1853 | "\n", 1854 | "It's important to note that a side effect of importing `seaborn` is that it changes *all* plot styles. For example, if you wanted to create the same line plot of Portugal's GDP over time using `matplotlib`, it would now look like the following since we've already imported searborn." 1855 | ] 1856 | }, 1857 | { 1858 | "cell_type": "code", 1859 | "execution_count": null, 1860 | "metadata": {}, 1861 | "outputs": [], 1862 | "source": [ 1863 | "plt.plot(portugal['year'], portugal['gdpPercap'])\n", 1864 | "plt.title('Per-capita GDP of Portugal')\n", 1865 | "plt.xlabel('Time (Years)')\n", 1866 | "plt.ylabel('Per-capita GPD (Millions of USD)');" 1867 | ] 1868 | }, 1869 | { 1870 | "cell_type": "markdown", 1871 | "metadata": {}, 1872 | "source": [ 1873 | "### `FacetGrid`\n", 1874 | "\n", 1875 | "In the previous `matplotlib` section we used `subplots` to make continent-specific scatter plots of per-capita GDP vs. life expectancy. Let's see how much easier that can be done using the `FacetGrid` in `seaborn`." 1876 | ] 1877 | }, 1878 | { 1879 | "cell_type": "code", 1880 | "execution_count": null, 1881 | "metadata": {}, 1882 | "outputs": [], 1883 | "source": [ 1884 | "g = sns.FacetGrid(gm, col='continent', col_wrap=3, height=4, sharex=False)\n", 1885 | "g.map(plt.scatter, 'gdpPercap', 'lifeExp', marker='.');" 1886 | ] 1887 | }, 1888 | { 1889 | "cell_type": "markdown", 1890 | "metadata": {}, 1891 | "source": [ 1892 | "That's pretty good, and quick. We are missing the color coding based on year however. To add this capability, and to shorten the code even further, we'll use a `relplot`, or relational plot." 1893 | ] 1894 | }, 1895 | { 1896 | "cell_type": "code", 1897 | "execution_count": null, 1898 | "metadata": {}, 1899 | "outputs": [], 1900 | "source": [ 1901 | "sns.relplot(x='gdpPercap', \n", 1902 | " y='lifeExp', \n", 1903 | " hue='year', \n", 1904 | " col='continent', \n", 1905 | " col_wrap=3, \n", 1906 | " palette='hot', \n", 1907 | " legend='full',\n", 1908 | " kind='scatter',\n", 1909 | " facet_kws={'sharex':False},\n", 1910 | " data=gm);" 1911 | ] 1912 | }, 1913 | { 1914 | "cell_type": "markdown", 1915 | "metadata": {}, 1916 | "source": [ 1917 | "You can also use `sns.relplot` for line plots. In fact, many `seaborn` plots can be easily plotted using a FacetGrid using another plotting function, just as `relplot` integrates a `FacetGrid` with either a `scatter` or `line` plot. See the [API documentation](https://seaborn.pydata.org/api.html) for more details." 1918 | ] 1919 | }, 1920 | { 1921 | "cell_type": "markdown", 1922 | "metadata": {}, 1923 | "source": [ 1924 | "## Saving Plots" 1925 | ] 1926 | }, 1927 | { 1928 | "cell_type": "markdown", 1929 | "metadata": {}, 1930 | "source": [ 1931 | "Finally, if you'd like to save a plot you can use the `plt.savefig` function that is part of the matplotlib package. This will create an image file saved to wherever you specify. Running the cell below will save the plot as `facetgrid_graph.png` within your current directory. Refer to `help(plt.savefig)` for more documentation on this function." 1932 | ] 1933 | }, 1934 | { 1935 | "cell_type": "code", 1936 | "execution_count": null, 1937 | "metadata": {}, 1938 | "outputs": [], 1939 | "source": [ 1940 | "sns.relplot(x='year', \n", 1941 | " y='gdpPercap', \n", 1942 | " hue='continent',\n", 1943 | " col='continent', \n", 1944 | " col_wrap=3, \n", 1945 | " legend=None,\n", 1946 | " kind='line',\n", 1947 | " facet_kws={'sharex':False},\n", 1948 | " data=per_continent_mean_gdp);\n", 1949 | "plt.savefig('facetgrid_graph.png')" 1950 | ] 1951 | }, 1952 | { 1953 | "cell_type": "markdown", 1954 | "metadata": {}, 1955 | "source": [ 1956 | "## Going further" 1957 | ] 1958 | }, 1959 | { 1960 | "cell_type": "markdown", 1961 | "metadata": {}, 1962 | "source": [ 1963 | "There are many visualization libraries in Python and you now have experience in using two popular ones.\n", 1964 | "\n", 1965 | "Several other Python visualization libraries exist for creating *interactive* visualizations such as [Plotly](https://plot.ly/python/), [Bokeh](http://bokeh.pydata.org/en/latest/), or [Toyplot](http://toyplot.readthedocs.org/en/stable/tutorial.html#getting-started)." 1966 | ] 1967 | } 1968 | ], 1969 | "metadata": { 1970 | "hide_input": false, 1971 | "kernelspec": { 1972 | "display_name": "Python 3 (ipykernel)", 1973 | "language": "python", 1974 | "name": "python3" 1975 | }, 1976 | "language_info": { 1977 | "codemirror_mode": { 1978 | "name": "ipython", 1979 | "version": 3 1980 | }, 1981 | "file_extension": ".py", 1982 | "mimetype": "text/x-python", 1983 | "name": "python", 1984 | "nbconvert_exporter": "python", 1985 | "pygments_lexer": "ipython3", 1986 | "version": "3.8.12" 1987 | }, 1988 | "toc": { 1989 | "base_numbering": 1, 1990 | "nav_menu": {}, 1991 | "number_sections": false, 1992 | "sideBar": true, 1993 | "skip_h1_title": false, 1994 | "title_cell": "Table of Contents", 1995 | "title_sidebar": "Contents", 1996 | "toc_cell": false, 1997 | "toc_position": { 1998 | "height": "calc(100% - 180px)", 1999 | "left": "10px", 2000 | "top": "150px", 2001 | "width": "235px" 2002 | }, 2003 | "toc_section_display": true, 2004 | "toc_window_display": true 2005 | }, 2006 | "varInspector": { 2007 | "cols": { 2008 | "lenName": 16, 2009 | "lenType": 16, 2010 | "lenVar": 40 2011 | }, 2012 | "kernels_config": { 2013 | "python": { 2014 | "delete_cmd_postfix": "", 2015 | "delete_cmd_prefix": "del ", 2016 | "library": "var_list.py", 2017 | "varRefreshCmd": "print(var_dic_list())" 2018 | }, 2019 | "r": { 2020 | "delete_cmd_postfix": ") ", 2021 | "delete_cmd_prefix": "rm(", 2022 | "library": "var_list.r", 2023 | "varRefreshCmd": "cat(var_dic_list()) " 2024 | } 2025 | }, 2026 | "types_to_exclude": [ 2027 | "module", 2028 | "function", 2029 | "builtin_function_or_method", 2030 | "instance", 2031 | "_Feature" 2032 | ], 2033 | "window_display": false 2034 | } 2035 | }, 2036 | "nbformat": 4, 2037 | "nbformat_minor": 4 2038 | } 2039 | -------------------------------------------------------------------------------- /data/gapminder.tsv: -------------------------------------------------------------------------------- 1 | country continent year lifeExp pop gdpPercap 2 | Afghanistan Asia 1952 28.801 8425333 779.4453145 3 | Afghanistan Asia 1957 30.332 9240934 820.8530296 4 | Afghanistan Asia 1962 31.997 10267083 853.10071 5 | Afghanistan Asia 1967 34.02 11537966 836.1971382 6 | Afghanistan Asia 1972 36.088 13079460 739.9811058 7 | Afghanistan Asia 1977 38.438 14880372 786.11336 8 | Afghanistan Asia 1982 39.854 12881816 978.0114388 9 | Afghanistan Asia 1987 40.822 13867957 852.3959448 10 | Afghanistan Asia 1992 41.674 16317921 649.3413952 11 | Afghanistan Asia 1997 41.763 22227415 635.341351 12 | Afghanistan Asia 2002 42.129 25268405 726.7340548 13 | Afghanistan Asia 2007 43.828 31889923 974.5803384 14 | Albania Europe 1952 55.23 1282697 1601.056136 15 | Albania Europe 1957 59.28 1476505 1942.284244 16 | Albania Europe 1962 64.82 1728137 2312.888958 17 | Albania Europe 1967 66.22 1984060 2760.196931 18 | Albania Europe 1972 67.69 2263554 3313.422188 19 | Albania Europe 1977 68.93 2509048 3533.00391 20 | Albania Europe 1982 70.42 2780097 3630.880722 21 | Albania Europe 1987 72 3075321 3738.932735 22 | Albania Europe 1992 71.581 3326498 2497.437901 23 | Albania Europe 1997 72.95 3428038 3193.054604 24 | Albania Europe 2002 75.651 3508512 4604.211737 25 | Albania Europe 2007 76.423 3600523 5937.029526 26 | Algeria Africa 1952 43.077 9279525 2449.008185 27 | Algeria Africa 1957 45.685 10270856 3013.976023 28 | Algeria Africa 1962 48.303 11000948 2550.81688 29 | Algeria Africa 1967 51.407 12760499 3246.991771 30 | Algeria Africa 1972 54.518 14760787 4182.663766 31 | Algeria Africa 1977 58.014 17152804 4910.416756 32 | Algeria Africa 1982 61.368 20033753 5745.160213 33 | Algeria Africa 1987 65.799 23254956 5681.358539 34 | Algeria Africa 1992 67.744 26298373 5023.216647 35 | Algeria Africa 1997 69.152 29072015 4797.295051 36 | Algeria Africa 2002 70.994 31287142 5288.040382 37 | Algeria Africa 2007 72.301 33333216 6223.367465 38 | Angola Africa 1952 30.015 4232095 3520.610273 39 | Angola Africa 1957 31.999 4561361 3827.940465 40 | Angola Africa 1962 34 4826015 4269.276742 41 | Angola Africa 1967 35.985 5247469 5522.776375 42 | Angola Africa 1972 37.928 5894858 5473.288005 43 | Angola Africa 1977 39.483 6162675 3008.647355 44 | Angola Africa 1982 39.942 7016384 2756.953672 45 | Angola Africa 1987 39.906 7874230 2430.208311 46 | Angola Africa 1992 40.647 8735988 2627.845685 47 | Angola Africa 1997 40.963 9875024 2277.140884 48 | Angola Africa 2002 41.003 10866106 2773.287312 49 | Angola Africa 2007 42.731 12420476 4797.231267 50 | Argentina Americas 1952 62.485 17876956 5911.315053 51 | Argentina Americas 1957 64.399 19610538 6856.856212 52 | Argentina Americas 1962 65.142 21283783 7133.166023 53 | Argentina Americas 1967 65.634 22934225 8052.953021 54 | Argentina Americas 1972 67.065 24779799 9443.038526 55 | Argentina Americas 1977 68.481 26983828 10079.02674 56 | Argentina Americas 1982 69.942 29341374 8997.897412 57 | Argentina Americas 1987 70.774 31620918 9139.671389 58 | Argentina Americas 1992 71.868 33958947 9308.41871 59 | Argentina Americas 1997 73.275 36203463 10967.28195 60 | Argentina Americas 2002 74.34 38331121 8797.640716 61 | Argentina Americas 2007 75.32 40301927 12779.37964 62 | Australia Oceania 1952 69.12 8691212 10039.59564 63 | Australia Oceania 1957 70.33 9712569 10949.64959 64 | Australia Oceania 1962 70.93 10794968 12217.22686 65 | Australia Oceania 1967 71.1 11872264 14526.12465 66 | Australia Oceania 1972 71.93 13177000 16788.62948 67 | Australia Oceania 1977 73.49 14074100 18334.19751 68 | Australia Oceania 1982 74.74 15184200 19477.00928 69 | Australia Oceania 1987 76.32 16257249 21888.88903 70 | Australia Oceania 1992 77.56 17481977 23424.76683 71 | Australia Oceania 1997 78.83 18565243 26997.93657 72 | Australia Oceania 2002 80.37 19546792 30687.75473 73 | Australia Oceania 2007 81.235 20434176 34435.36744 74 | Austria Europe 1952 66.8 6927772 6137.076492 75 | Austria Europe 1957 67.48 6965860 8842.59803 76 | Austria Europe 1962 69.54 7129864 10750.72111 77 | Austria Europe 1967 70.14 7376998 12834.6024 78 | Austria Europe 1972 70.63 7544201 16661.6256 79 | Austria Europe 1977 72.17 7568430 19749.4223 80 | Austria Europe 1982 73.18 7574613 21597.08362 81 | Austria Europe 1987 74.94 7578903 23687.82607 82 | Austria Europe 1992 76.04 7914969 27042.01868 83 | Austria Europe 1997 77.51 8069876 29095.92066 84 | Austria Europe 2002 78.98 8148312 32417.60769 85 | Austria Europe 2007 79.829 8199783 36126.4927 86 | Bahrain Asia 1952 50.939 120447 9867.084765 87 | Bahrain Asia 1957 53.832 138655 11635.79945 88 | Bahrain Asia 1962 56.923 171863 12753.27514 89 | Bahrain Asia 1967 59.923 202182 14804.6727 90 | Bahrain Asia 1972 63.3 230800 18268.65839 91 | Bahrain Asia 1977 65.593 297410 19340.10196 92 | Bahrain Asia 1982 69.052 377967 19211.14731 93 | Bahrain Asia 1987 70.75 454612 18524.02406 94 | Bahrain Asia 1992 72.601 529491 19035.57917 95 | Bahrain Asia 1997 73.925 598561 20292.01679 96 | Bahrain Asia 2002 74.795 656397 23403.55927 97 | Bahrain Asia 2007 75.635 708573 29796.04834 98 | Bangladesh Asia 1952 37.484 46886859 684.2441716 99 | Bangladesh Asia 1957 39.348 51365468 661.6374577 100 | Bangladesh Asia 1962 41.216 56839289 686.3415538 101 | Bangladesh Asia 1967 43.453 62821884 721.1860862 102 | Bangladesh Asia 1972 45.252 70759295 630.2336265 103 | Bangladesh Asia 1977 46.923 80428306 659.8772322 104 | Bangladesh Asia 1982 50.009 93074406 676.9818656 105 | Bangladesh Asia 1987 52.819 103764241 751.9794035 106 | Bangladesh Asia 1992 56.018 113704579 837.8101643 107 | Bangladesh Asia 1997 59.412 123315288 972.7700352 108 | Bangladesh Asia 2002 62.013 135656790 1136.39043 109 | Bangladesh Asia 2007 64.062 150448339 1391.253792 110 | Belgium Europe 1952 68 8730405 8343.105127 111 | Belgium Europe 1957 69.24 8989111 9714.960623 112 | Belgium Europe 1962 70.25 9218400 10991.20676 113 | Belgium Europe 1967 70.94 9556500 13149.04119 114 | Belgium Europe 1972 71.44 9709100 16672.14356 115 | Belgium Europe 1977 72.8 9821800 19117.97448 116 | Belgium Europe 1982 73.93 9856303 20979.84589 117 | Belgium Europe 1987 75.35 9870200 22525.56308 118 | Belgium Europe 1992 76.46 10045622 25575.57069 119 | Belgium Europe 1997 77.53 10199787 27561.19663 120 | Belgium Europe 2002 78.32 10311970 30485.88375 121 | Belgium Europe 2007 79.441 10392226 33692.60508 122 | Benin Africa 1952 38.223 1738315 1062.7522 123 | Benin Africa 1957 40.358 1925173 959.6010805 124 | Benin Africa 1962 42.618 2151895 949.4990641 125 | Benin Africa 1967 44.885 2427334 1035.831411 126 | Benin Africa 1972 47.014 2761407 1085.796879 127 | Benin Africa 1977 49.19 3168267 1029.161251 128 | Benin Africa 1982 50.904 3641603 1277.897616 129 | Benin Africa 1987 52.337 4243788 1225.85601 130 | Benin Africa 1992 53.919 4981671 1191.207681 131 | Benin Africa 1997 54.777 6066080 1232.975292 132 | Benin Africa 2002 54.406 7026113 1372.877931 133 | Benin Africa 2007 56.728 8078314 1441.284873 134 | Bolivia Americas 1952 40.414 2883315 2677.326347 135 | Bolivia Americas 1957 41.89 3211738 2127.686326 136 | Bolivia Americas 1962 43.428 3593918 2180.972546 137 | Bolivia Americas 1967 45.032 4040665 2586.886053 138 | Bolivia Americas 1972 46.714 4565872 2980.331339 139 | Bolivia Americas 1977 50.023 5079716 3548.097832 140 | Bolivia Americas 1982 53.859 5642224 3156.510452 141 | Bolivia Americas 1987 57.251 6156369 2753.69149 142 | Bolivia Americas 1992 59.957 6893451 2961.699694 143 | Bolivia Americas 1997 62.05 7693188 3326.143191 144 | Bolivia Americas 2002 63.883 8445134 3413.26269 145 | Bolivia Americas 2007 65.554 9119152 3822.137084 146 | Bosnia and Herzegovina Europe 1952 53.82 2791000 973.5331948 147 | Bosnia and Herzegovina Europe 1957 58.45 3076000 1353.989176 148 | Bosnia and Herzegovina Europe 1962 61.93 3349000 1709.683679 149 | Bosnia and Herzegovina Europe 1967 64.79 3585000 2172.352423 150 | Bosnia and Herzegovina Europe 1972 67.45 3819000 2860.16975 151 | Bosnia and Herzegovina Europe 1977 69.86 4086000 3528.481305 152 | Bosnia and Herzegovina Europe 1982 70.69 4172693 4126.613157 153 | Bosnia and Herzegovina Europe 1987 71.14 4338977 4314.114757 154 | Bosnia and Herzegovina Europe 1992 72.178 4256013 2546.781445 155 | Bosnia and Herzegovina Europe 1997 73.244 3607000 4766.355904 156 | Bosnia and Herzegovina Europe 2002 74.09 4165416 6018.975239 157 | Bosnia and Herzegovina Europe 2007 74.852 4552198 7446.298803 158 | Botswana Africa 1952 47.622 442308 851.2411407 159 | Botswana Africa 1957 49.618 474639 918.2325349 160 | Botswana Africa 1962 51.52 512764 983.6539764 161 | Botswana Africa 1967 53.298 553541 1214.709294 162 | Botswana Africa 1972 56.024 619351 2263.611114 163 | Botswana Africa 1977 59.319 781472 3214.857818 164 | Botswana Africa 1982 61.484 970347 4551.14215 165 | Botswana Africa 1987 63.622 1151184 6205.88385 166 | Botswana Africa 1992 62.745 1342614 7954.111645 167 | Botswana Africa 1997 52.556 1536536 8647.142313 168 | Botswana Africa 2002 46.634 1630347 11003.60508 169 | Botswana Africa 2007 50.728 1639131 12569.85177 170 | Brazil Americas 1952 50.917 56602560 2108.944355 171 | Brazil Americas 1957 53.285 65551171 2487.365989 172 | Brazil Americas 1962 55.665 76039390 3336.585802 173 | Brazil Americas 1967 57.632 88049823 3429.864357 174 | Brazil Americas 1972 59.504 100840058 4985.711467 175 | Brazil Americas 1977 61.489 114313951 6660.118654 176 | Brazil Americas 1982 63.336 128962939 7030.835878 177 | Brazil Americas 1987 65.205 142938076 7807.095818 178 | Brazil Americas 1992 67.057 155975974 6950.283021 179 | Brazil Americas 1997 69.388 168546719 7957.980824 180 | Brazil Americas 2002 71.006 179914212 8131.212843 181 | Brazil Americas 2007 72.39 190010647 9065.800825 182 | Bulgaria Europe 1952 59.6 7274900 2444.286648 183 | Bulgaria Europe 1957 66.61 7651254 3008.670727 184 | Bulgaria Europe 1962 69.51 8012946 4254.337839 185 | Bulgaria Europe 1967 70.42 8310226 5577.0028 186 | Bulgaria Europe 1972 70.9 8576200 6597.494398 187 | Bulgaria Europe 1977 70.81 8797022 7612.240438 188 | Bulgaria Europe 1982 71.08 8892098 8224.191647 189 | Bulgaria Europe 1987 71.34 8971958 8239.854824 190 | Bulgaria Europe 1992 71.19 8658506 6302.623438 191 | Bulgaria Europe 1997 70.32 8066057 5970.38876 192 | Bulgaria Europe 2002 72.14 7661799 7696.777725 193 | Bulgaria Europe 2007 73.005 7322858 10680.79282 194 | Burkina Faso Africa 1952 31.975 4469979 543.2552413 195 | Burkina Faso Africa 1957 34.906 4713416 617.1834648 196 | Burkina Faso Africa 1962 37.814 4919632 722.5120206 197 | Burkina Faso Africa 1967 40.697 5127935 794.8265597 198 | Burkina Faso Africa 1972 43.591 5433886 854.7359763 199 | Burkina Faso Africa 1977 46.137 5889574 743.3870368 200 | Burkina Faso Africa 1982 48.122 6634596 807.1985855 201 | Burkina Faso Africa 1987 49.557 7586551 912.0631417 202 | Burkina Faso Africa 1992 50.26 8878303 931.7527731 203 | Burkina Faso Africa 1997 50.324 10352843 946.2949618 204 | Burkina Faso Africa 2002 50.65 12251209 1037.645221 205 | Burkina Faso Africa 2007 52.295 14326203 1217.032994 206 | Burundi Africa 1952 39.031 2445618 339.2964587 207 | Burundi Africa 1957 40.533 2667518 379.5646281 208 | Burundi Africa 1962 42.045 2961915 355.2032273 209 | Burundi Africa 1967 43.548 3330989 412.9775136 210 | Burundi Africa 1972 44.057 3529983 464.0995039 211 | Burundi Africa 1977 45.91 3834415 556.1032651 212 | Burundi Africa 1982 47.471 4580410 559.603231 213 | Burundi Africa 1987 48.211 5126023 621.8188189 214 | Burundi Africa 1992 44.736 5809236 631.6998778 215 | Burundi Africa 1997 45.326 6121610 463.1151478 216 | Burundi Africa 2002 47.36 7021078 446.4035126 217 | Burundi Africa 2007 49.58 8390505 430.0706916 218 | Cambodia Asia 1952 39.417 4693836 368.4692856 219 | Cambodia Asia 1957 41.366 5322536 434.0383364 220 | Cambodia Asia 1962 43.415 6083619 496.9136476 221 | Cambodia Asia 1967 45.415 6960067 523.4323142 222 | Cambodia Asia 1972 40.317 7450606 421.6240257 223 | Cambodia Asia 1977 31.22 6978607 524.9721832 224 | Cambodia Asia 1982 50.957 7272485 624.4754784 225 | Cambodia Asia 1987 53.914 8371791 683.8955732 226 | Cambodia Asia 1992 55.803 10150094 682.3031755 227 | Cambodia Asia 1997 56.534 11782962 734.28517 228 | Cambodia Asia 2002 56.752 12926707 896.2260153 229 | Cambodia Asia 2007 59.723 14131858 1713.778686 230 | Cameroon Africa 1952 38.523 5009067 1172.667655 231 | Cameroon Africa 1957 40.428 5359923 1313.048099 232 | Cameroon Africa 1962 42.643 5793633 1399.607441 233 | Cameroon Africa 1967 44.799 6335506 1508.453148 234 | Cameroon Africa 1972 47.049 7021028 1684.146528 235 | Cameroon Africa 1977 49.355 7959865 1783.432873 236 | Cameroon Africa 1982 52.961 9250831 2367.983282 237 | Cameroon Africa 1987 54.985 10780667 2602.664206 238 | Cameroon Africa 1992 54.314 12467171 1793.163278 239 | Cameroon Africa 1997 52.199 14195809 1694.337469 240 | Cameroon Africa 2002 49.856 15929988 1934.011449 241 | Cameroon Africa 2007 50.43 17696293 2042.09524 242 | Canada Americas 1952 68.75 14785584 11367.16112 243 | Canada Americas 1957 69.96 17010154 12489.95006 244 | Canada Americas 1962 71.3 18985849 13462.48555 245 | Canada Americas 1967 72.13 20819767 16076.58803 246 | Canada Americas 1972 72.88 22284500 18970.57086 247 | Canada Americas 1977 74.21 23796400 22090.88306 248 | Canada Americas 1982 75.76 25201900 22898.79214 249 | Canada Americas 1987 76.86 26549700 26626.51503 250 | Canada Americas 1992 77.95 28523502 26342.88426 251 | Canada Americas 1997 78.61 30305843 28954.92589 252 | Canada Americas 2002 79.77 31902268 33328.96507 253 | Canada Americas 2007 80.653 33390141 36319.23501 254 | Central African Republic Africa 1952 35.463 1291695 1071.310713 255 | Central African Republic Africa 1957 37.464 1392284 1190.844328 256 | Central African Republic Africa 1962 39.475 1523478 1193.068753 257 | Central African Republic Africa 1967 41.478 1733638 1136.056615 258 | Central African Republic Africa 1972 43.457 1927260 1070.013275 259 | Central African Republic Africa 1977 46.775 2167533 1109.374338 260 | Central African Republic Africa 1982 48.295 2476971 956.7529907 261 | Central African Republic Africa 1987 50.485 2840009 844.8763504 262 | Central African Republic Africa 1992 49.396 3265124 747.9055252 263 | Central African Republic Africa 1997 46.066 3696513 740.5063317 264 | Central African Republic Africa 2002 43.308 4048013 738.6906068 265 | Central African Republic Africa 2007 44.741 4369038 706.016537 266 | Chad Africa 1952 38.092 2682462 1178.665927 267 | Chad Africa 1957 39.881 2894855 1308.495577 268 | Chad Africa 1962 41.716 3150417 1389.817618 269 | Chad Africa 1967 43.601 3495967 1196.810565 270 | Chad Africa 1972 45.569 3899068 1104.103987 271 | Chad Africa 1977 47.383 4388260 1133.98495 272 | Chad Africa 1982 49.517 4875118 797.9081006 273 | Chad Africa 1987 51.051 5498955 952.386129 274 | Chad Africa 1992 51.724 6429417 1058.0643 275 | Chad Africa 1997 51.573 7562011 1004.961353 276 | Chad Africa 2002 50.525 8835739 1156.18186 277 | Chad Africa 2007 50.651 10238807 1704.063724 278 | Chile Americas 1952 54.745 6377619 3939.978789 279 | Chile Americas 1957 56.074 7048426 4315.622723 280 | Chile Americas 1962 57.924 7961258 4519.094331 281 | Chile Americas 1967 60.523 8858908 5106.654313 282 | Chile Americas 1972 63.441 9717524 5494.024437 283 | Chile Americas 1977 67.052 10599793 4756.763836 284 | Chile Americas 1982 70.565 11487112 5095.665738 285 | Chile Americas 1987 72.492 12463354 5547.063754 286 | Chile Americas 1992 74.126 13572994 7596.125964 287 | Chile Americas 1997 75.816 14599929 10118.05318 288 | Chile Americas 2002 77.86 15497046 10778.78385 289 | Chile Americas 2007 78.553 16284741 13171.63885 290 | China Asia 1952 44 556263527.999989 400.448610699994 291 | China Asia 1957 50.54896 637408000 575.9870009 292 | China Asia 1962 44.50136 665770000 487.6740183 293 | China Asia 1967 58.38112 754550000 612.7056934 294 | China Asia 1972 63.11888 862030000 676.9000921 295 | China Asia 1977 63.96736 943455000 741.2374699 296 | China Asia 1982 65.525 1000281000 962.4213805 297 | China Asia 1987 67.274 1084035000 1378.904018 298 | China Asia 1992 68.69 1164970000 1655.784158 299 | China Asia 1997 70.426 1230075000 2289.234136 300 | China Asia 2002 72.028 1280400000 3119.280896 301 | China Asia 2007 72.961 1318683096 4959.114854 302 | Colombia Americas 1952 50.643 12350771 2144.115096 303 | Colombia Americas 1957 55.118 14485993 2323.805581 304 | Colombia Americas 1962 57.863 17009885 2492.351109 305 | Colombia Americas 1967 59.963 19764027 2678.729839 306 | Colombia Americas 1972 61.623 22542890 3264.660041 307 | Colombia Americas 1977 63.837 25094412 3815.80787 308 | Colombia Americas 1982 66.653 27764644 4397.575659 309 | Colombia Americas 1987 67.768 30964245 4903.2191 310 | Colombia Americas 1992 68.421 34202721 5444.648617 311 | Colombia Americas 1997 70.313 37657830 6117.361746 312 | Colombia Americas 2002 71.682 41008227 5755.259962 313 | Colombia Americas 2007 72.889 44227550 7006.580419 314 | Comoros Africa 1952 40.715 153936 1102.990936 315 | Comoros Africa 1957 42.46 170928 1211.148548 316 | Comoros Africa 1962 44.467 191689 1406.648278 317 | Comoros Africa 1967 46.472 217378 1876.029643 318 | Comoros Africa 1972 48.944 250027 1937.577675 319 | Comoros Africa 1977 50.939 304739 1172.603047 320 | Comoros Africa 1982 52.933 348643 1267.100083 321 | Comoros Africa 1987 54.926 395114 1315.980812 322 | Comoros Africa 1992 57.939 454429 1246.90737 323 | Comoros Africa 1997 60.66 527982 1173.618235 324 | Comoros Africa 2002 62.974 614382 1075.811558 325 | Comoros Africa 2007 65.152 710960 986.1478792 326 | Congo, Dem. Rep. Africa 1952 39.143 14100005 780.5423257 327 | Congo, Dem. Rep. Africa 1957 40.652 15577932 905.8602303 328 | Congo, Dem. Rep. Africa 1962 42.122 17486434 896.3146335 329 | Congo, Dem. Rep. Africa 1967 44.056 19941073 861.5932424 330 | Congo, Dem. Rep. Africa 1972 45.989 23007669 904.8960685 331 | Congo, Dem. Rep. Africa 1977 47.804 26480870 795.757282 332 | Congo, Dem. Rep. Africa 1982 47.784 30646495 673.7478181 333 | Congo, Dem. Rep. Africa 1987 47.412 35481645 672.774812 334 | Congo, Dem. Rep. Africa 1992 45.548 41672143 457.7191807 335 | Congo, Dem. Rep. Africa 1997 42.587 47798986 312.188423 336 | Congo, Dem. Rep. Africa 2002 44.966 55379852 241.1658765 337 | Congo, Dem. Rep. Africa 2007 46.462 64606759 277.5518587 338 | Congo, Rep. Africa 1952 42.111 854885 2125.621418 339 | Congo, Rep. Africa 1957 45.053 940458 2315.056572 340 | Congo, Rep. Africa 1962 48.435 1047924 2464.783157 341 | Congo, Rep. Africa 1967 52.04 1179760 2677.939642 342 | Congo, Rep. Africa 1972 54.907 1340458 3213.152683 343 | Congo, Rep. Africa 1977 55.625 1536769 3259.178978 344 | Congo, Rep. Africa 1982 56.695 1774735 4879.507522 345 | Congo, Rep. Africa 1987 57.47 2064095 4201.194937 346 | Congo, Rep. Africa 1992 56.433 2409073 4016.239529 347 | Congo, Rep. Africa 1997 52.962 2800947 3484.164376 348 | Congo, Rep. Africa 2002 52.97 3328795 3484.06197 349 | Congo, Rep. Africa 2007 55.322 3800610 3632.557798 350 | Costa Rica Americas 1952 57.206 926317 2627.009471 351 | Costa Rica Americas 1957 60.026 1112300 2990.010802 352 | Costa Rica Americas 1962 62.842 1345187 3460.937025 353 | Costa Rica Americas 1967 65.424 1588717 4161.727834 354 | Costa Rica Americas 1972 67.849 1834796 5118.146939 355 | Costa Rica Americas 1977 70.75 2108457 5926.876967 356 | Costa Rica Americas 1982 73.45 2424367 5262.734751 357 | Costa Rica Americas 1987 74.752 2799811 5629.915318 358 | Costa Rica Americas 1992 75.713 3173216 6160.416317 359 | Costa Rica Americas 1997 77.26 3518107 6677.045314 360 | Costa Rica Americas 2002 78.123 3834934 7723.447195 361 | Costa Rica Americas 2007 78.782 4133884 9645.06142 362 | Cote d'Ivoire Africa 1952 40.477 2977019 1388.594732 363 | Cote d'Ivoire Africa 1957 42.469 3300000 1500.895925 364 | Cote d'Ivoire Africa 1962 44.93 3832408 1728.869428 365 | Cote d'Ivoire Africa 1967 47.35 4744870 2052.050473 366 | Cote d'Ivoire Africa 1972 49.801 6071696 2378.201111 367 | Cote d'Ivoire Africa 1977 52.374 7459574 2517.736547 368 | Cote d'Ivoire Africa 1982 53.983 9025951 2602.710169 369 | Cote d'Ivoire Africa 1987 54.655 10761098 2156.956069 370 | Cote d'Ivoire Africa 1992 52.044 12772596 1648.073791 371 | Cote d'Ivoire Africa 1997 47.991 14625967 1786.265407 372 | Cote d'Ivoire Africa 2002 46.832 16252726 1648.800823 373 | Cote d'Ivoire Africa 2007 48.328 18013409 1544.750112 374 | Croatia Europe 1952 61.21 3882229 3119.23652 375 | Croatia Europe 1957 64.77 3991242 4338.231617 376 | Croatia Europe 1962 67.13 4076557 5477.890018 377 | Croatia Europe 1967 68.5 4174366 6960.297861 378 | Croatia Europe 1972 69.61 4225310 9164.090127 379 | Croatia Europe 1977 70.64 4318673 11305.38517 380 | Croatia Europe 1982 70.46 4413368 13221.82184 381 | Croatia Europe 1987 71.52 4484310 13822.58394 382 | Croatia Europe 1992 72.527 4494013 8447.794873 383 | Croatia Europe 1997 73.68 4444595 9875.604515 384 | Croatia Europe 2002 74.876 4481020 11628.38895 385 | Croatia Europe 2007 75.748 4493312 14619.22272 386 | Cuba Americas 1952 59.421 6007797 5586.53878 387 | Cuba Americas 1957 62.325 6640752 6092.174359 388 | Cuba Americas 1962 65.246 7254373 5180.75591 389 | Cuba Americas 1967 68.29 8139332 5690.268015 390 | Cuba Americas 1972 70.723 8831348 5305.445256 391 | Cuba Americas 1977 72.649 9537988 6380.494966 392 | Cuba Americas 1982 73.717 9789224 7316.918107 393 | Cuba Americas 1987 74.174 10239839 7532.924763 394 | Cuba Americas 1992 74.414 10723260 5592.843963 395 | Cuba Americas 1997 76.151 10983007 5431.990415 396 | Cuba Americas 2002 77.158 11226999 6340.646683 397 | Cuba Americas 2007 78.273 11416987 8948.102923 398 | Czech Republic Europe 1952 66.87 9125183 6876.14025 399 | Czech Republic Europe 1957 69.03 9513758 8256.343918 400 | Czech Republic Europe 1962 69.9 9620282 10136.86713 401 | Czech Republic Europe 1967 70.38 9835109 11399.44489 402 | Czech Republic Europe 1972 70.29 9862158 13108.4536 403 | Czech Republic Europe 1977 70.71 10161915 14800.16062 404 | Czech Republic Europe 1982 70.96 10303704 15377.22855 405 | Czech Republic Europe 1987 71.58 10311597 16310.4434 406 | Czech Republic Europe 1992 72.4 10315702 14297.02122 407 | Czech Republic Europe 1997 74.01 10300707 16048.51424 408 | Czech Republic Europe 2002 75.51 10256295 17596.21022 409 | Czech Republic Europe 2007 76.486 10228744 22833.30851 410 | Denmark Europe 1952 70.78 4334000 9692.385245 411 | Denmark Europe 1957 71.81 4487831 11099.65935 412 | Denmark Europe 1962 72.35 4646899 13583.31351 413 | Denmark Europe 1967 72.96 4838800 15937.21123 414 | Denmark Europe 1972 73.47 4991596 18866.20721 415 | Denmark Europe 1977 74.69 5088419 20422.9015 416 | Denmark Europe 1982 74.63 5117810 21688.04048 417 | Denmark Europe 1987 74.8 5127024 25116.17581 418 | Denmark Europe 1992 75.33 5171393 26406.73985 419 | Denmark Europe 1997 76.11 5283663 29804.34567 420 | Denmark Europe 2002 77.18 5374693 32166.50006 421 | Denmark Europe 2007 78.332 5468120 35278.41874 422 | Djibouti Africa 1952 34.812 63149 2669.529475 423 | Djibouti Africa 1957 37.328 71851 2864.969076 424 | Djibouti Africa 1962 39.693 89898 3020.989263 425 | Djibouti Africa 1967 42.074 127617 3020.050513 426 | Djibouti Africa 1972 44.366 178848 3694.212352 427 | Djibouti Africa 1977 46.519 228694 3081.761022 428 | Djibouti Africa 1982 48.812 305991 2879.468067 429 | Djibouti Africa 1987 50.04 311025 2880.102568 430 | Djibouti Africa 1992 51.604 384156 2377.156192 431 | Djibouti Africa 1997 53.157 417908 1895.016984 432 | Djibouti Africa 2002 53.373 447416 1908.260867 433 | Djibouti Africa 2007 54.791 496374 2082.481567 434 | Dominican Republic Americas 1952 45.928 2491346 1397.717137 435 | Dominican Republic Americas 1957 49.828 2923186 1544.402995 436 | Dominican Republic Americas 1962 53.459 3453434 1662.137359 437 | Dominican Republic Americas 1967 56.751 4049146 1653.723003 438 | Dominican Republic Americas 1972 59.631 4671329 2189.874499 439 | Dominican Republic Americas 1977 61.788 5302800 2681.9889 440 | Dominican Republic Americas 1982 63.727 5968349 2861.092386 441 | Dominican Republic Americas 1987 66.046 6655297 2899.842175 442 | Dominican Republic Americas 1992 68.457 7351181 3044.214214 443 | Dominican Republic Americas 1997 69.957 7992357 3614.101285 444 | Dominican Republic Americas 2002 70.847 8650322 4563.808154 445 | Dominican Republic Americas 2007 72.235 9319622 6025.374752 446 | Ecuador Americas 1952 48.357 3548753 3522.110717 447 | Ecuador Americas 1957 51.356 4058385 3780.546651 448 | Ecuador Americas 1962 54.64 4681707 4086.114078 449 | Ecuador Americas 1967 56.678 5432424 4579.074215 450 | Ecuador Americas 1972 58.796 6298651 5280.99471 451 | Ecuador Americas 1977 61.31 7278866 6679.62326 452 | Ecuador Americas 1982 64.342 8365850 7213.791267 453 | Ecuador Americas 1987 67.231 9545158 6481.776993 454 | Ecuador Americas 1992 69.613 10748394 7103.702595 455 | Ecuador Americas 1997 72.312 11911819 7429.455877 456 | Ecuador Americas 2002 74.173 12921234 5773.044512 457 | Ecuador Americas 2007 74.994 13755680 6873.262326 458 | Egypt Africa 1952 41.893 22223309 1418.822445 459 | Egypt Africa 1957 44.444 25009741 1458.915272 460 | Egypt Africa 1962 46.992 28173309 1693.335853 461 | Egypt Africa 1967 49.293 31681188 1814.880728 462 | Egypt Africa 1972 51.137 34807417 2024.008147 463 | Egypt Africa 1977 53.319 38783863 2785.493582 464 | Egypt Africa 1982 56.006 45681811 3503.729636 465 | Egypt Africa 1987 59.797 52799062 3885.46071 466 | Egypt Africa 1992 63.674 59402198 3794.755195 467 | Egypt Africa 1997 67.217 66134291 4173.181797 468 | Egypt Africa 2002 69.806 73312559 4754.604414 469 | Egypt Africa 2007 71.338 80264543 5581.180998 470 | El Salvador Americas 1952 45.262 2042865 3048.3029 471 | El Salvador Americas 1957 48.57 2355805 3421.523218 472 | El Salvador Americas 1962 52.307 2747687 3776.803627 473 | El Salvador Americas 1967 55.855 3232927 4358.595393 474 | El Salvador Americas 1972 58.207 3790903 4520.246008 475 | El Salvador Americas 1977 56.696 4282586 5138.922374 476 | El Salvador Americas 1982 56.604 4474873 4098.344175 477 | El Salvador Americas 1987 63.154 4842194 4140.442097 478 | El Salvador Americas 1992 66.798 5274649 4444.2317 479 | El Salvador Americas 1997 69.535 5783439 5154.825496 480 | El Salvador Americas 2002 70.734 6353681 5351.568666 481 | El Salvador Americas 2007 71.878 6939688 5728.353514 482 | Equatorial Guinea Africa 1952 34.482 216964 375.6431231 483 | Equatorial Guinea Africa 1957 35.983 232922 426.0964081 484 | Equatorial Guinea Africa 1962 37.485 249220 582.8419714 485 | Equatorial Guinea Africa 1967 38.987 259864 915.5960025 486 | Equatorial Guinea Africa 1972 40.516 277603 672.4122571 487 | Equatorial Guinea Africa 1977 42.024 192675 958.5668124 488 | Equatorial Guinea Africa 1982 43.662 285483 927.8253427 489 | Equatorial Guinea Africa 1987 45.664 341244 966.8968149 490 | Equatorial Guinea Africa 1992 47.545 387838 1132.055034 491 | Equatorial Guinea Africa 1997 48.245 439971 2814.480755 492 | Equatorial Guinea Africa 2002 49.348 495627 7703.4959 493 | Equatorial Guinea Africa 2007 51.579 551201 12154.08975 494 | Eritrea Africa 1952 35.928 1438760 328.9405571 495 | Eritrea Africa 1957 38.047 1542611 344.1618859 496 | Eritrea Africa 1962 40.158 1666618 380.9958433 497 | Eritrea Africa 1967 42.189 1820319 468.7949699 498 | Eritrea Africa 1972 44.142 2260187 514.3242082 499 | Eritrea Africa 1977 44.535 2512642 505.7538077 500 | Eritrea Africa 1982 43.89 2637297 524.8758493 501 | Eritrea Africa 1987 46.453 2915959 521.1341333 502 | Eritrea Africa 1992 49.991 3668440 582.8585102 503 | Eritrea Africa 1997 53.378 4058319 913.47079 504 | Eritrea Africa 2002 55.24 4414865 765.3500015 505 | Eritrea Africa 2007 58.04 4906585 641.3695236 506 | Ethiopia Africa 1952 34.078 20860941 362.1462796 507 | Ethiopia Africa 1957 36.667 22815614 378.9041632 508 | Ethiopia Africa 1962 40.059 25145372 419.4564161 509 | Ethiopia Africa 1967 42.115 27860297 516.1186438 510 | Ethiopia Africa 1972 43.515 30770372 566.2439442 511 | Ethiopia Africa 1977 44.51 34617799 556.8083834 512 | Ethiopia Africa 1982 44.916 38111756 577.8607471 513 | Ethiopia Africa 1987 46.684 42999530 573.7413142 514 | Ethiopia Africa 1992 48.091 52088559 421.3534653 515 | Ethiopia Africa 1997 49.402 59861301 515.8894013 516 | Ethiopia Africa 2002 50.725 67946797 530.0535319 517 | Ethiopia Africa 2007 52.947 76511887 690.8055759 518 | Finland Europe 1952 66.55 4090500 6424.519071 519 | Finland Europe 1957 67.49 4324000 7545.415386 520 | Finland Europe 1962 68.75 4491443 9371.842561 521 | Finland Europe 1967 69.83 4605744 10921.63626 522 | Finland Europe 1972 70.87 4639657 14358.8759 523 | Finland Europe 1977 72.52 4738902 15605.42283 524 | Finland Europe 1982 74.55 4826933 18533.15761 525 | Finland Europe 1987 74.83 4931729 21141.01223 526 | Finland Europe 1992 75.7 5041039 20647.16499 527 | Finland Europe 1997 77.13 5134406 23723.9502 528 | Finland Europe 2002 78.37 5193039 28204.59057 529 | Finland Europe 2007 79.313 5238460 33207.0844 530 | France Europe 1952 67.41 42459667 7029.809327 531 | France Europe 1957 68.93 44310863 8662.834898 532 | France Europe 1962 70.51 47124000 10560.48553 533 | France Europe 1967 71.55 49569000 12999.91766 534 | France Europe 1972 72.38 51732000 16107.19171 535 | France Europe 1977 73.83 53165019 18292.63514 536 | France Europe 1982 74.89 54433565 20293.89746 537 | France Europe 1987 76.34 55630100 22066.44214 538 | France Europe 1992 77.46 57374179 24703.79615 539 | France Europe 1997 78.64 58623428 25889.78487 540 | France Europe 2002 79.59 59925035 28926.03234 541 | France Europe 2007 80.657 61083916 30470.0167 542 | Gabon Africa 1952 37.003 420702 4293.476475 543 | Gabon Africa 1957 38.999 434904 4976.198099 544 | Gabon Africa 1962 40.489 455661 6631.459222 545 | Gabon Africa 1967 44.598 489004 8358.761987 546 | Gabon Africa 1972 48.69 537977 11401.94841 547 | Gabon Africa 1977 52.79 706367 21745.57328 548 | Gabon Africa 1982 56.564 753874 15113.36194 549 | Gabon Africa 1987 60.19 880397 11864.40844 550 | Gabon Africa 1992 61.366 985739 13522.15752 551 | Gabon Africa 1997 60.461 1126189 14722.84188 552 | Gabon Africa 2002 56.761 1299304 12521.71392 553 | Gabon Africa 2007 56.735 1454867 13206.48452 554 | Gambia Africa 1952 30 284320 485.2306591 555 | Gambia Africa 1957 32.065 323150 520.9267111 556 | Gambia Africa 1962 33.896 374020 599.650276 557 | Gambia Africa 1967 35.857 439593 734.7829124 558 | Gambia Africa 1972 38.308 517101 756.0868363 559 | Gambia Africa 1977 41.842 608274 884.7552507 560 | Gambia Africa 1982 45.58 715523 835.8096108 561 | Gambia Africa 1987 49.265 848406 611.6588611 562 | Gambia Africa 1992 52.644 1025384 665.6244126 563 | Gambia Africa 1997 55.861 1235767 653.7301704 564 | Gambia Africa 2002 58.041 1457766 660.5855997 565 | Gambia Africa 2007 59.448 1688359 752.7497265 566 | Germany Europe 1952 67.5 69145952 7144.114393 567 | Germany Europe 1957 69.1 71019069 10187.82665 568 | Germany Europe 1962 70.3 73739117 12902.46291 569 | Germany Europe 1967 70.8 76368453 14745.62561 570 | Germany Europe 1972 71 78717088 18016.18027 571 | Germany Europe 1977 72.5 78160773 20512.92123 572 | Germany Europe 1982 73.8 78335266 22031.53274 573 | Germany Europe 1987 74.847 77718298 24639.18566 574 | Germany Europe 1992 76.07 80597764 26505.30317 575 | Germany Europe 1997 77.34 82011073 27788.88416 576 | Germany Europe 2002 78.67 82350671 30035.80198 577 | Germany Europe 2007 79.406 82400996 32170.37442 578 | Ghana Africa 1952 43.149 5581001 911.2989371 579 | Ghana Africa 1957 44.779 6391288 1043.561537 580 | Ghana Africa 1962 46.452 7355248 1190.041118 581 | Ghana Africa 1967 48.072 8490213 1125.69716 582 | Ghana Africa 1972 49.875 9354120 1178.223708 583 | Ghana Africa 1977 51.756 10538093 993.2239571 584 | Ghana Africa 1982 53.744 11400338 876.032569 585 | Ghana Africa 1987 55.729 14168101 847.0061135 586 | Ghana Africa 1992 57.501 16278738 925.060154 587 | Ghana Africa 1997 58.556 18418288 1005.245812 588 | Ghana Africa 2002 58.453 20550751 1111.984578 589 | Ghana Africa 2007 60.022 22873338 1327.60891 590 | Greece Europe 1952 65.86 7733250 3530.690067 591 | Greece Europe 1957 67.86 8096218 4916.299889 592 | Greece Europe 1962 69.51 8448233 6017.190733 593 | Greece Europe 1967 71 8716441 8513.097016 594 | Greece Europe 1972 72.34 8888628 12724.82957 595 | Greece Europe 1977 73.68 9308479 14195.52428 596 | Greece Europe 1982 75.24 9786480 15268.42089 597 | Greece Europe 1987 76.67 9974490 16120.52839 598 | Greece Europe 1992 77.03 10325429 17541.49634 599 | Greece Europe 1997 77.869 10502372 18747.69814 600 | Greece Europe 2002 78.256 10603863 22514.2548 601 | Greece Europe 2007 79.483 10706290 27538.41188 602 | Guatemala Americas 1952 42.023 3146381 2428.237769 603 | Guatemala Americas 1957 44.142 3640876 2617.155967 604 | Guatemala Americas 1962 46.954 4208858 2750.364446 605 | Guatemala Americas 1967 50.016 4690773 3242.531147 606 | Guatemala Americas 1972 53.738 5149581 4031.408271 607 | Guatemala Americas 1977 56.029 5703430 4879.992748 608 | Guatemala Americas 1982 58.137 6395630 4820.49479 609 | Guatemala Americas 1987 60.782 7326406 4246.485974 610 | Guatemala Americas 1992 63.373 8486949 4439.45084 611 | Guatemala Americas 1997 66.322 9803875 4684.313807 612 | Guatemala Americas 2002 68.978 11178650 4858.347495 613 | Guatemala Americas 2007 70.259 12572928 5186.050003 614 | Guinea Africa 1952 33.609 2664249 510.1964923 615 | Guinea Africa 1957 34.558 2876726 576.2670245 616 | Guinea Africa 1962 35.753 3140003 686.3736739 617 | Guinea Africa 1967 37.197 3451418 708.7595409 618 | Guinea Africa 1972 38.842 3811387 741.6662307 619 | Guinea Africa 1977 40.762 4227026 874.6858643 620 | Guinea Africa 1982 42.891 4710497 857.2503577 621 | Guinea Africa 1987 45.552 5650262 805.5724718 622 | Guinea Africa 1992 48.576 6990574 794.3484384 623 | Guinea Africa 1997 51.455 8048834 869.4497668 624 | Guinea Africa 2002 53.676 8807818 945.5835837 625 | Guinea Africa 2007 56.007 9947814 942.6542111 626 | Guinea-Bissau Africa 1952 32.5 580653 299.850319 627 | Guinea-Bissau Africa 1957 33.489 601095 431.7904566 628 | Guinea-Bissau Africa 1962 34.488 627820 522.0343725 629 | Guinea-Bissau Africa 1967 35.492 601287 715.5806402 630 | Guinea-Bissau Africa 1972 36.486 625361 820.2245876 631 | Guinea-Bissau Africa 1977 37.465 745228 764.7259628 632 | Guinea-Bissau Africa 1982 39.327 825987 838.1239671 633 | Guinea-Bissau Africa 1987 41.245 927524 736.4153921 634 | Guinea-Bissau Africa 1992 43.266 1050938 745.5398706 635 | Guinea-Bissau Africa 1997 44.873 1193708 796.6644681 636 | Guinea-Bissau Africa 2002 45.504 1332459 575.7047176 637 | Guinea-Bissau Africa 2007 46.388 1472041 579.231743 638 | Haiti Americas 1952 37.579 3201488 1840.366939 639 | Haiti Americas 1957 40.696 3507701 1726.887882 640 | Haiti Americas 1962 43.59 3880130 1796.589032 641 | Haiti Americas 1967 46.243 4318137 1452.057666 642 | Haiti Americas 1972 48.042 4698301 1654.456946 643 | Haiti Americas 1977 49.923 4908554 1874.298931 644 | Haiti Americas 1982 51.461 5198399 2011.159549 645 | Haiti Americas 1987 53.636 5756203 1823.015995 646 | Haiti Americas 1992 55.089 6326682 1456.309517 647 | Haiti Americas 1997 56.671 6913545 1341.726931 648 | Haiti Americas 2002 58.137 7607651 1270.364932 649 | Haiti Americas 2007 60.916 8502814 1201.637154 650 | Honduras Americas 1952 41.912 1517453 2194.926204 651 | Honduras Americas 1957 44.665 1770390 2220.487682 652 | Honduras Americas 1962 48.041 2090162 2291.156835 653 | Honduras Americas 1967 50.924 2500689 2538.269358 654 | Honduras Americas 1972 53.884 2965146 2529.842345 655 | Honduras Americas 1977 57.402 3055235 3203.208066 656 | Honduras Americas 1982 60.909 3669448 3121.760794 657 | Honduras Americas 1987 64.492 4372203 3023.096699 658 | Honduras Americas 1992 66.399 5077347 3081.694603 659 | Honduras Americas 1997 67.659 5867957 3160.454906 660 | Honduras Americas 2002 68.565 6677328 3099.72866 661 | Honduras Americas 2007 70.198 7483763 3548.330846 662 | Hong Kong, China Asia 1952 60.96 2125900 3054.421209 663 | Hong Kong, China Asia 1957 64.75 2736300 3629.076457 664 | Hong Kong, China Asia 1962 67.65 3305200 4692.648272 665 | Hong Kong, China Asia 1967 70 3722800 6197.962814 666 | Hong Kong, China Asia 1972 72 4115700 8315.928145 667 | Hong Kong, China Asia 1977 73.6 4583700 11186.14125 668 | Hong Kong, China Asia 1982 75.45 5264500 14560.53051 669 | Hong Kong, China Asia 1987 76.2 5584510 20038.47269 670 | Hong Kong, China Asia 1992 77.601 5829696 24757.60301 671 | Hong Kong, China Asia 1997 80 6495918 28377.63219 672 | Hong Kong, China Asia 2002 81.495 6762476 30209.01516 673 | Hong Kong, China Asia 2007 82.208 6980412 39724.97867 674 | Hungary Europe 1952 64.03 9504000 5263.673816 675 | Hungary Europe 1957 66.41 9839000 6040.180011 676 | Hungary Europe 1962 67.96 10063000 7550.359877 677 | Hungary Europe 1967 69.5 10223422 9326.64467 678 | Hungary Europe 1972 69.76 10394091 10168.65611 679 | Hungary Europe 1977 69.95 10637171 11674.83737 680 | Hungary Europe 1982 69.39 10705535 12545.99066 681 | Hungary Europe 1987 69.58 10612740 12986.47998 682 | Hungary Europe 1992 69.17 10348684 10535.62855 683 | Hungary Europe 1997 71.04 10244684 11712.7768 684 | Hungary Europe 2002 72.59 10083313 14843.93556 685 | Hungary Europe 2007 73.338 9956108 18008.94444 686 | Iceland Europe 1952 72.49 147962 7267.688428 687 | Iceland Europe 1957 73.47 165110 9244.001412 688 | Iceland Europe 1962 73.68 182053 10350.15906 689 | Iceland Europe 1967 73.73 198676 13319.89568 690 | Iceland Europe 1972 74.46 209275 15798.06362 691 | Iceland Europe 1977 76.11 221823 19654.96247 692 | Iceland Europe 1982 76.99 233997 23269.6075 693 | Iceland Europe 1987 77.23 244676 26923.20628 694 | Iceland Europe 1992 78.77 259012 25144.39201 695 | Iceland Europe 1997 78.95 271192 28061.09966 696 | Iceland Europe 2002 80.5 288030 31163.20196 697 | Iceland Europe 2007 81.757 301931 36180.78919 698 | India Asia 1952 37.373 3.72e+08 546.5657493 699 | India Asia 1957 40.249 4.09e+08 590.061996 700 | India Asia 1962 43.605 4.54e+08 658.3471509 701 | India Asia 1967 47.193 5.06e+08 700.7706107 702 | India Asia 1972 50.651 5.67e+08 724.032527 703 | India Asia 1977 54.208 6.34e+08 813.337323 704 | India Asia 1982 56.596 7.08e+08 855.7235377 705 | India Asia 1987 58.553 7.88e+08 976.5126756 706 | India Asia 1992 60.223 8.72e+08 1164.406809 707 | India Asia 1997 61.765 9.59e+08 1458.817442 708 | India Asia 2002 62.879 1034172547 1746.769454 709 | India Asia 2007 64.698 1110396331 2452.210407 710 | Indonesia Asia 1952 37.468 82052000 749.6816546 711 | Indonesia Asia 1957 39.918 90124000 858.9002707 712 | Indonesia Asia 1962 42.518 99028000 849.2897701 713 | Indonesia Asia 1967 45.964 109343000 762.4317721 714 | Indonesia Asia 1972 49.203 121282000 1111.107907 715 | Indonesia Asia 1977 52.702 136725000 1382.702056 716 | Indonesia Asia 1982 56.159 153343000 1516.872988 717 | Indonesia Asia 1987 60.137 169276000 1748.356961 718 | Indonesia Asia 1992 62.681 184816000 2383.140898 719 | Indonesia Asia 1997 66.041 199278000 3119.335603 720 | Indonesia Asia 2002 68.588 211060000 2873.91287 721 | Indonesia Asia 2007 70.65 223547000 3540.651564 722 | Iran Asia 1952 44.869 17272000 3035.326002 723 | Iran Asia 1957 47.181 19792000 3290.257643 724 | Iran Asia 1962 49.325 22874000 4187.329802 725 | Iran Asia 1967 52.469 26538000 5906.731805 726 | Iran Asia 1972 55.234 30614000 9613.818607 727 | Iran Asia 1977 57.702 35480679 11888.59508 728 | Iran Asia 1982 59.62 43072751 7608.334602 729 | Iran Asia 1987 63.04 51889696 6642.881371 730 | Iran Asia 1992 65.742 60397973 7235.653188 731 | Iran Asia 1997 68.042 63327987 8263.590301 732 | Iran Asia 2002 69.451 66907826 9240.761975 733 | Iran Asia 2007 70.964 69453570 11605.71449 734 | Iraq Asia 1952 45.32 5441766 4129.766056 735 | Iraq Asia 1957 48.437 6248643 6229.333562 736 | Iraq Asia 1962 51.457 7240260 8341.737815 737 | Iraq Asia 1967 54.459 8519282 8931.459811 738 | Iraq Asia 1972 56.95 10061506 9576.037596 739 | Iraq Asia 1977 60.413 11882916 14688.23507 740 | Iraq Asia 1982 62.038 14173318 14517.90711 741 | Iraq Asia 1987 65.044 16543189 11643.57268 742 | Iraq Asia 1992 59.461 17861905 3745.640687 743 | Iraq Asia 1997 58.811 20775703 3076.239795 744 | Iraq Asia 2002 57.046 24001816 4390.717312 745 | Iraq Asia 2007 59.545 27499638 4471.061906 746 | Ireland Europe 1952 66.91 2952156 5210.280328 747 | Ireland Europe 1957 68.9 2878220 5599.077872 748 | Ireland Europe 1962 70.29 2830000 6631.597314 749 | Ireland Europe 1967 71.08 2900100 7655.568963 750 | Ireland Europe 1972 71.28 3024400 9530.772896 751 | Ireland Europe 1977 72.03 3271900 11150.98113 752 | Ireland Europe 1982 73.1 3480000 12618.32141 753 | Ireland Europe 1987 74.36 3539900 13872.86652 754 | Ireland Europe 1992 75.467 3557761 17558.81555 755 | Ireland Europe 1997 76.122 3667233 24521.94713 756 | Ireland Europe 2002 77.783 3879155 34077.04939 757 | Ireland Europe 2007 78.885 4109086 40675.99635 758 | Israel Asia 1952 65.39 1620914 4086.522128 759 | Israel Asia 1957 67.84 1944401 5385.278451 760 | Israel Asia 1962 69.39 2310904 7105.630706 761 | Israel Asia 1967 70.75 2693585 8393.741404 762 | Israel Asia 1972 71.63 3095893 12786.93223 763 | Israel Asia 1977 73.06 3495918 13306.61921 764 | Israel Asia 1982 74.45 3858421 15367.0292 765 | Israel Asia 1987 75.6 4203148 17122.47986 766 | Israel Asia 1992 76.93 4936550 18051.52254 767 | Israel Asia 1997 78.269 5531387 20896.60924 768 | Israel Asia 2002 79.696 6029529 21905.59514 769 | Israel Asia 2007 80.745 6426679 25523.2771 770 | Italy Europe 1952 65.94 47666000 4931.404155 771 | Italy Europe 1957 67.81 49182000 6248.656232 772 | Italy Europe 1962 69.24 50843200 8243.58234 773 | Italy Europe 1967 71.06 52667100 10022.40131 774 | Italy Europe 1972 72.19 54365564 12269.27378 775 | Italy Europe 1977 73.48 56059245 14255.98475 776 | Italy Europe 1982 74.98 56535636 16537.4835 777 | Italy Europe 1987 76.42 56729703 19207.23482 778 | Italy Europe 1992 77.44 56840847 22013.64486 779 | Italy Europe 1997 78.82 57479469 24675.02446 780 | Italy Europe 2002 80.24 57926999 27968.09817 781 | Italy Europe 2007 80.546 58147733 28569.7197 782 | Jamaica Americas 1952 58.53 1426095 2898.530881 783 | Jamaica Americas 1957 62.61 1535090 4756.525781 784 | Jamaica Americas 1962 65.61 1665128 5246.107524 785 | Jamaica Americas 1967 67.51 1861096 6124.703451 786 | Jamaica Americas 1972 69 1997616 7433.889293 787 | Jamaica Americas 1977 70.11 2156814 6650.195573 788 | Jamaica Americas 1982 71.21 2298309 6068.05135 789 | Jamaica Americas 1987 71.77 2326606 6351.237495 790 | Jamaica Americas 1992 71.766 2378618 7404.923685 791 | Jamaica Americas 1997 72.262 2531311 7121.924704 792 | Jamaica Americas 2002 72.047 2664659 6994.774861 793 | Jamaica Americas 2007 72.567 2780132 7320.880262 794 | Japan Asia 1952 63.03 86459025 3216.956347 795 | Japan Asia 1957 65.5 91563009 4317.694365 796 | Japan Asia 1962 68.73 95831757 6576.649461 797 | Japan Asia 1967 71.43 100825279 9847.788607 798 | Japan Asia 1972 73.42 107188273 14778.78636 799 | Japan Asia 1977 75.38 113872473 16610.37701 800 | Japan Asia 1982 77.11 118454974 19384.10571 801 | Japan Asia 1987 78.67 122091325 22375.94189 802 | Japan Asia 1992 79.36 124329269 26824.89511 803 | Japan Asia 1997 80.69 125956499 28816.58499 804 | Japan Asia 2002 82 127065841 28604.5919 805 | Japan Asia 2007 82.603 127467972 31656.06806 806 | Jordan Asia 1952 43.158 607914 1546.907807 807 | Jordan Asia 1957 45.669 746559 1886.080591 808 | Jordan Asia 1962 48.126 933559 2348.009158 809 | Jordan Asia 1967 51.629 1255058 2741.796252 810 | Jordan Asia 1972 56.528 1613551 2110.856309 811 | Jordan Asia 1977 61.134 1937652 2852.351568 812 | Jordan Asia 1982 63.739 2347031 4161.415959 813 | Jordan Asia 1987 65.869 2820042 4448.679912 814 | Jordan Asia 1992 68.015 3867409 3431.593647 815 | Jordan Asia 1997 69.772 4526235 3645.379572 816 | Jordan Asia 2002 71.263 5307470 3844.917194 817 | Jordan Asia 2007 72.535 6053193 4519.461171 818 | Kenya Africa 1952 42.27 6464046 853.540919 819 | Kenya Africa 1957 44.686 7454779 944.4383152 820 | Kenya Africa 1962 47.949 8678557 896.9663732 821 | Kenya Africa 1967 50.654 10191512 1056.736457 822 | Kenya Africa 1972 53.559 12044785 1222.359968 823 | Kenya Africa 1977 56.155 14500404 1267.613204 824 | Kenya Africa 1982 58.766 17661452 1348.225791 825 | Kenya Africa 1987 59.339 21198082 1361.936856 826 | Kenya Africa 1992 59.285 25020539 1341.921721 827 | Kenya Africa 1997 54.407 28263827 1360.485021 828 | Kenya Africa 2002 50.992 31386842 1287.514732 829 | Kenya Africa 2007 54.11 35610177 1463.249282 830 | Korea, Dem. Rep. Asia 1952 50.056 8865488 1088.277758 831 | Korea, Dem. Rep. Asia 1957 54.081 9411381 1571.134655 832 | Korea, Dem. Rep. Asia 1962 56.656 10917494 1621.693598 833 | Korea, Dem. Rep. Asia 1967 59.942 12617009 2143.540609 834 | Korea, Dem. Rep. Asia 1972 63.983 14781241 3701.621503 835 | Korea, Dem. Rep. Asia 1977 67.159 16325320 4106.301249 836 | Korea, Dem. Rep. Asia 1982 69.1 17647518 4106.525293 837 | Korea, Dem. Rep. Asia 1987 70.647 19067554 4106.492315 838 | Korea, Dem. Rep. Asia 1992 69.978 20711375 3726.063507 839 | Korea, Dem. Rep. Asia 1997 67.727 21585105 1690.756814 840 | Korea, Dem. Rep. Asia 2002 66.662 22215365 1646.758151 841 | Korea, Dem. Rep. Asia 2007 67.297 23301725 1593.06548 842 | Korea, Rep. Asia 1952 47.453 20947571 1030.592226 843 | Korea, Rep. Asia 1957 52.681 22611552 1487.593537 844 | Korea, Rep. Asia 1962 55.292 26420307 1536.344387 845 | Korea, Rep. Asia 1967 57.716 30131000 2029.228142 846 | Korea, Rep. Asia 1972 62.612 33505000 3030.87665 847 | Korea, Rep. Asia 1977 64.766 36436000 4657.22102 848 | Korea, Rep. Asia 1982 67.123 39326000 5622.942464 849 | Korea, Rep. Asia 1987 69.81 41622000 8533.088805 850 | Korea, Rep. Asia 1992 72.244 43805450 12104.27872 851 | Korea, Rep. Asia 1997 74.647 46173816 15993.52796 852 | Korea, Rep. Asia 2002 77.045 47969150 19233.98818 853 | Korea, Rep. Asia 2007 78.623 49044790 23348.13973 854 | Kuwait Asia 1952 55.565 160000 108382.3529 855 | Kuwait Asia 1957 58.033 212846 113523.1329 856 | Kuwait Asia 1962 60.47 358266 95458.11176 857 | Kuwait Asia 1967 64.624 575003 80894.88326 858 | Kuwait Asia 1972 67.712 841934 109347.867 859 | Kuwait Asia 1977 69.343 1140357 59265.47714 860 | Kuwait Asia 1982 71.309 1497494 31354.03573 861 | Kuwait Asia 1987 74.174 1891487 28118.42998 862 | Kuwait Asia 1992 75.19 1418095 34932.91959 863 | Kuwait Asia 1997 76.156 1765345 40300.61996 864 | Kuwait Asia 2002 76.904 2111561 35110.10566 865 | Kuwait Asia 2007 77.588 2505559 47306.98978 866 | Lebanon Asia 1952 55.928 1439529 4834.804067 867 | Lebanon Asia 1957 59.489 1647412 6089.786934 868 | Lebanon Asia 1962 62.094 1886848 5714.560611 869 | Lebanon Asia 1967 63.87 2186894 6006.983042 870 | Lebanon Asia 1972 65.421 2680018 7486.384341 871 | Lebanon Asia 1977 66.099 3115787 8659.696836 872 | Lebanon Asia 1982 66.983 3086876 7640.519521 873 | Lebanon Asia 1987 67.926 3089353 5377.091329 874 | Lebanon Asia 1992 69.292 3219994 6890.806854 875 | Lebanon Asia 1997 70.265 3430388 8754.96385 876 | Lebanon Asia 2002 71.028 3677780 9313.93883 877 | Lebanon Asia 2007 71.993 3921278 10461.05868 878 | Lesotho Africa 1952 42.138 748747 298.8462121 879 | Lesotho Africa 1957 45.047 813338 335.9971151 880 | Lesotho Africa 1962 47.747 893143 411.8006266 881 | Lesotho Africa 1967 48.492 996380 498.6390265 882 | Lesotho Africa 1972 49.767 1116779 496.5815922 883 | Lesotho Africa 1977 52.208 1251524 745.3695408 884 | Lesotho Africa 1982 55.078 1411807 797.2631074 885 | Lesotho Africa 1987 57.18 1599200 773.9932141 886 | Lesotho Africa 1992 59.685 1803195 977.4862725 887 | Lesotho Africa 1997 55.558 1982823 1186.147994 888 | Lesotho Africa 2002 44.593 2046772 1275.184575 889 | Lesotho Africa 2007 42.592 2012649 1569.331442 890 | Liberia Africa 1952 38.48 863308 575.5729961 891 | Liberia Africa 1957 39.486 975950 620.9699901 892 | Liberia Africa 1962 40.502 1112796 634.1951625 893 | Liberia Africa 1967 41.536 1279406 713.6036483 894 | Liberia Africa 1972 42.614 1482628 803.0054535 895 | Liberia Africa 1977 43.764 1703617 640.3224383 896 | Liberia Africa 1982 44.852 1956875 572.1995694 897 | Liberia Africa 1987 46.027 2269414 506.1138573 898 | Liberia Africa 1992 40.802 1912974 636.6229191 899 | Liberia Africa 1997 42.221 2200725 609.1739508 900 | Liberia Africa 2002 43.753 2814651 531.4823679 901 | Liberia Africa 2007 45.678 3193942 414.5073415 902 | Libya Africa 1952 42.723 1019729 2387.54806 903 | Libya Africa 1957 45.289 1201578 3448.284395 904 | Libya Africa 1962 47.808 1441863 6757.030816 905 | Libya Africa 1967 50.227 1759224 18772.75169 906 | Libya Africa 1972 52.773 2183877 21011.49721 907 | Libya Africa 1977 57.442 2721783 21951.21176 908 | Libya Africa 1982 62.155 3344074 17364.27538 909 | Libya Africa 1987 66.234 3799845 11770.5898 910 | Libya Africa 1992 68.755 4364501 9640.138501 911 | Libya Africa 1997 71.555 4759670 9467.446056 912 | Libya Africa 2002 72.737 5368585 9534.677467 913 | Libya Africa 2007 73.952 6036914 12057.49928 914 | Madagascar Africa 1952 36.681 4762912 1443.011715 915 | Madagascar Africa 1957 38.865 5181679 1589.20275 916 | Madagascar Africa 1962 40.848 5703324 1643.38711 917 | Madagascar Africa 1967 42.881 6334556 1634.047282 918 | Madagascar Africa 1972 44.851 7082430 1748.562982 919 | Madagascar Africa 1977 46.881 8007166 1544.228586 920 | Madagascar Africa 1982 48.969 9171477 1302.878658 921 | Madagascar Africa 1987 49.35 10568642 1155.441948 922 | Madagascar Africa 1992 52.214 12210395 1040.67619 923 | Madagascar Africa 1997 54.978 14165114 986.2958956 924 | Madagascar Africa 2002 57.286 16473477 894.6370822 925 | Madagascar Africa 2007 59.443 19167654 1044.770126 926 | Malawi Africa 1952 36.256 2917802 369.1650802 927 | Malawi Africa 1957 37.207 3221238 416.3698064 928 | Malawi Africa 1962 38.41 3628608 427.9010856 929 | Malawi Africa 1967 39.487 4147252 495.5147806 930 | Malawi Africa 1972 41.766 4730997 584.6219709 931 | Malawi Africa 1977 43.767 5637246 663.2236766 932 | Malawi Africa 1982 45.642 6502825 632.8039209 933 | Malawi Africa 1987 47.457 7824747 635.5173634 934 | Malawi Africa 1992 49.42 10014249 563.2000145 935 | Malawi Africa 1997 47.495 10419991 692.2758103 936 | Malawi Africa 2002 45.009 11824495 665.4231186 937 | Malawi Africa 2007 48.303 13327079 759.3499101 938 | Malaysia Asia 1952 48.463 6748378 1831.132894 939 | Malaysia Asia 1957 52.102 7739235 1810.066992 940 | Malaysia Asia 1962 55.737 8906385 2036.884944 941 | Malaysia Asia 1967 59.371 10154878 2277.742396 942 | Malaysia Asia 1972 63.01 11441462 2849.09478 943 | Malaysia Asia 1977 65.256 12845381 3827.921571 944 | Malaysia Asia 1982 68 14441916 4920.355951 945 | Malaysia Asia 1987 69.5 16331785 5249.802653 946 | Malaysia Asia 1992 70.693 18319502 7277.912802 947 | Malaysia Asia 1997 71.938 20476091 10132.90964 948 | Malaysia Asia 2002 73.044 22662365 10206.97794 949 | Malaysia Asia 2007 74.241 24821286 12451.6558 950 | Mali Africa 1952 33.685 3838168 452.3369807 951 | Mali Africa 1957 35.307 4241884 490.3821867 952 | Mali Africa 1962 36.936 4690372 496.1743428 953 | Mali Africa 1967 38.487 5212416 545.0098873 954 | Mali Africa 1972 39.977 5828158 581.3688761 955 | Mali Africa 1977 41.714 6491649 686.3952693 956 | Mali Africa 1982 43.916 6998256 618.0140641 957 | Mali Africa 1987 46.364 7634008 684.1715576 958 | Mali Africa 1992 48.388 8416215 739.014375 959 | Mali Africa 1997 49.903 9384984 790.2579846 960 | Mali Africa 2002 51.818 10580176 951.4097518 961 | Mali Africa 2007 54.467 12031795 1042.581557 962 | Mauritania Africa 1952 40.543 1022556 743.1159097 963 | Mauritania Africa 1957 42.338 1076852 846.1202613 964 | Mauritania Africa 1962 44.248 1146757 1055.896036 965 | Mauritania Africa 1967 46.289 1230542 1421.145193 966 | Mauritania Africa 1972 48.437 1332786 1586.851781 967 | Mauritania Africa 1977 50.852 1456688 1497.492223 968 | Mauritania Africa 1982 53.599 1622136 1481.150189 969 | Mauritania Africa 1987 56.145 1841240 1421.603576 970 | Mauritania Africa 1992 58.333 2119465 1361.369784 971 | Mauritania Africa 1997 60.43 2444741 1483.136136 972 | Mauritania Africa 2002 62.247 2828858 1579.019543 973 | Mauritania Africa 2007 64.164 3270065 1803.151496 974 | Mauritius Africa 1952 50.986 516556 1967.955707 975 | Mauritius Africa 1957 58.089 609816 2034.037981 976 | Mauritius Africa 1962 60.246 701016 2529.067487 977 | Mauritius Africa 1967 61.557 789309 2475.387562 978 | Mauritius Africa 1972 62.944 851334 2575.484158 979 | Mauritius Africa 1977 64.93 913025 3710.982963 980 | Mauritius Africa 1982 66.711 992040 3688.037739 981 | Mauritius Africa 1987 68.74 1042663 4783.586903 982 | Mauritius Africa 1992 69.745 1096202 6058.253846 983 | Mauritius Africa 1997 70.736 1149818 7425.705295 984 | Mauritius Africa 2002 71.954 1200206 9021.815894 985 | Mauritius Africa 2007 72.801 1250882 10956.99112 986 | Mexico Americas 1952 50.789 30144317 3478.125529 987 | Mexico Americas 1957 55.19 35015548 4131.546641 988 | Mexico Americas 1962 58.299 41121485 4581.609385 989 | Mexico Americas 1967 60.11 47995559 5754.733883 990 | Mexico Americas 1972 62.361 55984294 6809.40669 991 | Mexico Americas 1977 65.032 63759976 7674.929108 992 | Mexico Americas 1982 67.405 71640904 9611.147541 993 | Mexico Americas 1987 69.498 80122492 8688.156003 994 | Mexico Americas 1992 71.455 88111030 9472.384295 995 | Mexico Americas 1997 73.67 95895146 9767.29753 996 | Mexico Americas 2002 74.902 102479927 10742.44053 997 | Mexico Americas 2007 76.195 108700891 11977.57496 998 | Mongolia Asia 1952 42.244 800663 786.5668575 999 | Mongolia Asia 1957 45.248 882134 912.6626085 1000 | Mongolia Asia 1962 48.251 1010280 1056.353958 1001 | Mongolia Asia 1967 51.253 1149500 1226.04113 1002 | Mongolia Asia 1972 53.754 1320500 1421.741975 1003 | Mongolia Asia 1977 55.491 1528000 1647.511665 1004 | Mongolia Asia 1982 57.489 1756032 2000.603139 1005 | Mongolia Asia 1987 60.222 2015133 2338.008304 1006 | Mongolia Asia 1992 61.271 2312802 1785.402016 1007 | Mongolia Asia 1997 63.625 2494803 1902.2521 1008 | Mongolia Asia 2002 65.033 2674234 2140.739323 1009 | Mongolia Asia 2007 66.803 2874127 3095.772271 1010 | Montenegro Europe 1952 59.164 413834 2647.585601 1011 | Montenegro Europe 1957 61.448 442829 3682.259903 1012 | Montenegro Europe 1962 63.728 474528 4649.593785 1013 | Montenegro Europe 1967 67.178 501035 5907.850937 1014 | Montenegro Europe 1972 70.636 527678 7778.414017 1015 | Montenegro Europe 1977 73.066 560073 9595.929905 1016 | Montenegro Europe 1982 74.101 562548 11222.58762 1017 | Montenegro Europe 1987 74.865 569473 11732.51017 1018 | Montenegro Europe 1992 75.435 621621 7003.339037 1019 | Montenegro Europe 1997 75.445 692651 6465.613349 1020 | Montenegro Europe 2002 73.981 720230 6557.194282 1021 | Montenegro Europe 2007 74.543 684736 9253.896111 1022 | Morocco Africa 1952 42.873 9939217 1688.20357 1023 | Morocco Africa 1957 45.423 11406350 1642.002314 1024 | Morocco Africa 1962 47.924 13056604 1566.353493 1025 | Morocco Africa 1967 50.335 14770296 1711.04477 1026 | Morocco Africa 1972 52.862 16660670 1930.194975 1027 | Morocco Africa 1977 55.73 18396941 2370.619976 1028 | Morocco Africa 1982 59.65 20198730 2702.620356 1029 | Morocco Africa 1987 62.677 22987397 2755.046991 1030 | Morocco Africa 1992 65.393 25798239 2948.047252 1031 | Morocco Africa 1997 67.66 28529501 2982.101858 1032 | Morocco Africa 2002 69.615 31167783 3258.495584 1033 | Morocco Africa 2007 71.164 33757175 3820.17523 1034 | Mozambique Africa 1952 31.286 6446316 468.5260381 1035 | Mozambique Africa 1957 33.779 7038035 495.5868333 1036 | Mozambique Africa 1962 36.161 7788944 556.6863539 1037 | Mozambique Africa 1967 38.113 8680909 566.6691539 1038 | Mozambique Africa 1972 40.328 9809596 724.9178037 1039 | Mozambique Africa 1977 42.495 11127868 502.3197334 1040 | Mozambique Africa 1982 42.795 12587223 462.2114149 1041 | Mozambique Africa 1987 42.861 12891952 389.8761846 1042 | Mozambique Africa 1992 44.284 13160731 410.8968239 1043 | Mozambique Africa 1997 46.344 16603334 472.3460771 1044 | Mozambique Africa 2002 44.026 18473780 633.6179466 1045 | Mozambique Africa 2007 42.082 19951656 823.6856205 1046 | Myanmar Asia 1952 36.319 20092996 331 1047 | Myanmar Asia 1957 41.905 21731844 350 1048 | Myanmar Asia 1962 45.108 23634436 388 1049 | Myanmar Asia 1967 49.379 25870271 349 1050 | Myanmar Asia 1972 53.07 28466390 357 1051 | Myanmar Asia 1977 56.059 31528087 371 1052 | Myanmar Asia 1982 58.056 34680442 424 1053 | Myanmar Asia 1987 58.339 38028578 385 1054 | Myanmar Asia 1992 59.32 40546538 347 1055 | Myanmar Asia 1997 60.328 43247867 415 1056 | Myanmar Asia 2002 59.908 45598081 611 1057 | Myanmar Asia 2007 62.069 47761980 944 1058 | Namibia Africa 1952 41.725 485831 2423.780443 1059 | Namibia Africa 1957 45.226 548080 2621.448058 1060 | Namibia Africa 1962 48.386 621392 3173.215595 1061 | Namibia Africa 1967 51.159 706640 3793.694753 1062 | Namibia Africa 1972 53.867 821782 3746.080948 1063 | Namibia Africa 1977 56.437 977026 3876.485958 1064 | Namibia Africa 1982 58.968 1099010 4191.100511 1065 | Namibia Africa 1987 60.835 1278184 3693.731337 1066 | Namibia Africa 1992 61.999 1554253 3804.537999 1067 | Namibia Africa 1997 58.909 1774766 3899.52426 1068 | Namibia Africa 2002 51.479 1972153 4072.324751 1069 | Namibia Africa 2007 52.906 2055080 4811.060429 1070 | Nepal Asia 1952 36.157 9182536 545.8657229 1071 | Nepal Asia 1957 37.686 9682338 597.9363558 1072 | Nepal Asia 1962 39.393 10332057 652.3968593 1073 | Nepal Asia 1967 41.472 11261690 676.4422254 1074 | Nepal Asia 1972 43.971 12412593 674.7881296 1075 | Nepal Asia 1977 46.748 13933198 694.1124398 1076 | Nepal Asia 1982 49.594 15796314 718.3730947 1077 | Nepal Asia 1987 52.537 17917180 775.6324501 1078 | Nepal Asia 1992 55.727 20326209 897.7403604 1079 | Nepal Asia 1997 59.426 23001113 1010.892138 1080 | Nepal Asia 2002 61.34 25873917 1057.206311 1081 | Nepal Asia 2007 63.785 28901790 1091.359778 1082 | Netherlands Europe 1952 72.13 10381988 8941.571858 1083 | Netherlands Europe 1957 72.99 11026383 11276.19344 1084 | Netherlands Europe 1962 73.23 11805689 12790.84956 1085 | Netherlands Europe 1967 73.82 12596822 15363.25136 1086 | Netherlands Europe 1972 73.75 13329874 18794.74567 1087 | Netherlands Europe 1977 75.24 13852989 21209.0592 1088 | Netherlands Europe 1982 76.05 14310401 21399.46046 1089 | Netherlands Europe 1987 76.83 14665278 23651.32361 1090 | Netherlands Europe 1992 77.42 15174244 26790.94961 1091 | Netherlands Europe 1997 78.03 15604464 30246.13063 1092 | Netherlands Europe 2002 78.53 16122830 33724.75778 1093 | Netherlands Europe 2007 79.762 16570613 36797.93332 1094 | New Zealand Oceania 1952 69.39 1994794 10556.57566 1095 | New Zealand Oceania 1957 70.26 2229407 12247.39532 1096 | New Zealand Oceania 1962 71.24 2488550 13175.678 1097 | New Zealand Oceania 1967 71.52 2728150 14463.91893 1098 | New Zealand Oceania 1972 71.89 2929100 16046.03728 1099 | New Zealand Oceania 1977 72.22 3164900 16233.7177 1100 | New Zealand Oceania 1982 73.84 3210650 17632.4104 1101 | New Zealand Oceania 1987 74.32 3317166 19007.19129 1102 | New Zealand Oceania 1992 76.33 3437674 18363.32494 1103 | New Zealand Oceania 1997 77.55 3676187 21050.41377 1104 | New Zealand Oceania 2002 79.11 3908037 23189.80135 1105 | New Zealand Oceania 2007 80.204 4115771 25185.00911 1106 | Nicaragua Americas 1952 42.314 1165790 3112.363948 1107 | Nicaragua Americas 1957 45.432 1358828 3457.415947 1108 | Nicaragua Americas 1962 48.632 1590597 3634.364406 1109 | Nicaragua Americas 1967 51.884 1865490 4643.393534 1110 | Nicaragua Americas 1972 55.151 2182908 4688.593267 1111 | Nicaragua Americas 1977 57.47 2554598 5486.371089 1112 | Nicaragua Americas 1982 59.298 2979423 3470.338156 1113 | Nicaragua Americas 1987 62.008 3344353 2955.984375 1114 | Nicaragua Americas 1992 65.843 4017939 2170.151724 1115 | Nicaragua Americas 1997 68.426 4609572 2253.023004 1116 | Nicaragua Americas 2002 70.836 5146848 2474.548819 1117 | Nicaragua Americas 2007 72.899 5675356 2749.320965 1118 | Niger Africa 1952 37.444 3379468 761.879376 1119 | Niger Africa 1957 38.598 3692184 835.5234025 1120 | Niger Africa 1962 39.487 4076008 997.7661127 1121 | Niger Africa 1967 40.118 4534062 1054.384891 1122 | Niger Africa 1972 40.546 5060262 954.2092363 1123 | Niger Africa 1977 41.291 5682086 808.8970728 1124 | Niger Africa 1982 42.598 6437188 909.7221354 1125 | Niger Africa 1987 44.555 7332638 668.3000228 1126 | Niger Africa 1992 47.391 8392818 581.182725 1127 | Niger Africa 1997 51.313 9666252 580.3052092 1128 | Niger Africa 2002 54.496 11140655 601.0745012 1129 | Niger Africa 2007 56.867 12894865 619.6768924 1130 | Nigeria Africa 1952 36.324 33119096 1077.281856 1131 | Nigeria Africa 1957 37.802 37173340 1100.592563 1132 | Nigeria Africa 1962 39.36 41871351 1150.927478 1133 | Nigeria Africa 1967 41.04 47287752 1014.514104 1134 | Nigeria Africa 1972 42.821 53740085 1698.388838 1135 | Nigeria Africa 1977 44.514 62209173 1981.951806 1136 | Nigeria Africa 1982 45.826 73039376 1576.97375 1137 | Nigeria Africa 1987 46.886 81551520 1385.029563 1138 | Nigeria Africa 1992 47.472 93364244 1619.848217 1139 | Nigeria Africa 1997 47.464 106207839 1624.941275 1140 | Nigeria Africa 2002 46.608 119901274 1615.286395 1141 | Nigeria Africa 2007 46.859 135031164 2013.977305 1142 | Norway Europe 1952 72.67 3327728 10095.42172 1143 | Norway Europe 1957 73.44 3491938 11653.97304 1144 | Norway Europe 1962 73.47 3638919 13450.40151 1145 | Norway Europe 1967 74.08 3786019 16361.87647 1146 | Norway Europe 1972 74.34 3933004 18965.05551 1147 | Norway Europe 1977 75.37 4043205 23311.34939 1148 | Norway Europe 1982 75.97 4114787 26298.63531 1149 | Norway Europe 1987 75.89 4186147 31540.9748 1150 | Norway Europe 1992 77.32 4286357 33965.66115 1151 | Norway Europe 1997 78.32 4405672 41283.16433 1152 | Norway Europe 2002 79.05 4535591 44683.97525 1153 | Norway Europe 2007 80.196 4627926 49357.19017 1154 | Oman Asia 1952 37.578 507833 1828.230307 1155 | Oman Asia 1957 40.08 561977 2242.746551 1156 | Oman Asia 1962 43.165 628164 2924.638113 1157 | Oman Asia 1967 46.988 714775 4720.942687 1158 | Oman Asia 1972 52.143 829050 10618.03855 1159 | Oman Asia 1977 57.367 1004533 11848.34392 1160 | Oman Asia 1982 62.728 1301048 12954.79101 1161 | Oman Asia 1987 67.734 1593882 18115.22313 1162 | Oman Asia 1992 71.197 1915208 18616.70691 1163 | Oman Asia 1997 72.499 2283635 19702.05581 1164 | Oman Asia 2002 74.193 2713462 19774.83687 1165 | Oman Asia 2007 75.64 3204897 22316.19287 1166 | Pakistan Asia 1952 43.436 41346560 684.5971438 1167 | Pakistan Asia 1957 45.557 46679944 747.0835292 1168 | Pakistan Asia 1962 47.67 53100671 803.3427418 1169 | Pakistan Asia 1967 49.8 60641899 942.4082588 1170 | Pakistan Asia 1972 51.929 69325921 1049.938981 1171 | Pakistan Asia 1977 54.043 78152686 1175.921193 1172 | Pakistan Asia 1982 56.158 91462088 1443.429832 1173 | Pakistan Asia 1987 58.245 105186881 1704.686583 1174 | Pakistan Asia 1992 60.838 120065004 1971.829464 1175 | Pakistan Asia 1997 61.818 135564834 2049.350521 1176 | Pakistan Asia 2002 63.61 153403524 2092.712441 1177 | Pakistan Asia 2007 65.483 169270617 2605.94758 1178 | Panama Americas 1952 55.191 940080 2480.380334 1179 | Panama Americas 1957 59.201 1063506 2961.800905 1180 | Panama Americas 1962 61.817 1215725 3536.540301 1181 | Panama Americas 1967 64.071 1405486 4421.009084 1182 | Panama Americas 1972 66.216 1616384 5364.249663 1183 | Panama Americas 1977 68.681 1839782 5351.912144 1184 | Panama Americas 1982 70.472 2036305 7009.601598 1185 | Panama Americas 1987 71.523 2253639 7034.779161 1186 | Panama Americas 1992 72.462 2484997 6618.74305 1187 | Panama Americas 1997 73.738 2734531 7113.692252 1188 | Panama Americas 2002 74.712 2990875 7356.031934 1189 | Panama Americas 2007 75.537 3242173 9809.185636 1190 | Paraguay Americas 1952 62.649 1555876 1952.308701 1191 | Paraguay Americas 1957 63.196 1770902 2046.154706 1192 | Paraguay Americas 1962 64.361 2009813 2148.027146 1193 | Paraguay Americas 1967 64.951 2287985 2299.376311 1194 | Paraguay Americas 1972 65.815 2614104 2523.337977 1195 | Paraguay Americas 1977 66.353 2984494 3248.373311 1196 | Paraguay Americas 1982 66.874 3366439 4258.503604 1197 | Paraguay Americas 1987 67.378 3886512 3998.875695 1198 | Paraguay Americas 1992 68.225 4483945 4196.411078 1199 | Paraguay Americas 1997 69.4 5154123 4247.400261 1200 | Paraguay Americas 2002 70.755 5884491 3783.674243 1201 | Paraguay Americas 2007 71.752 6667147 4172.838464 1202 | Peru Americas 1952 43.902 8025700 3758.523437 1203 | Peru Americas 1957 46.263 9146100 4245.256698 1204 | Peru Americas 1962 49.096 10516500 4957.037982 1205 | Peru Americas 1967 51.445 12132200 5788.09333 1206 | Peru Americas 1972 55.448 13954700 5937.827283 1207 | Peru Americas 1977 58.447 15990099 6281.290855 1208 | Peru Americas 1982 61.406 18125129 6434.501797 1209 | Peru Americas 1987 64.134 20195924 6360.943444 1210 | Peru Americas 1992 66.458 22430449 4446.380924 1211 | Peru Americas 1997 68.386 24748122 5838.347657 1212 | Peru Americas 2002 69.906 26769436 5909.020073 1213 | Peru Americas 2007 71.421 28674757 7408.905561 1214 | Philippines Asia 1952 47.752 22438691 1272.880995 1215 | Philippines Asia 1957 51.334 26072194 1547.944844 1216 | Philippines Asia 1962 54.757 30325264 1649.552153 1217 | Philippines Asia 1967 56.393 35356600 1814.12743 1218 | Philippines Asia 1972 58.065 40850141 1989.37407 1219 | Philippines Asia 1977 60.06 46850962 2373.204287 1220 | Philippines Asia 1982 62.082 53456774 2603.273765 1221 | Philippines Asia 1987 64.151 60017788 2189.634995 1222 | Philippines Asia 1992 66.458 67185766 2279.324017 1223 | Philippines Asia 1997 68.564 75012988 2536.534925 1224 | Philippines Asia 2002 70.303 82995088 2650.921068 1225 | Philippines Asia 2007 71.688 91077287 3190.481016 1226 | Poland Europe 1952 61.31 25730551 4029.329699 1227 | Poland Europe 1957 65.77 28235346 4734.253019 1228 | Poland Europe 1962 67.64 30329617 5338.752143 1229 | Poland Europe 1967 69.61 31785378 6557.152776 1230 | Poland Europe 1972 70.85 33039545 8006.506993 1231 | Poland Europe 1977 70.67 34621254 9508.141454 1232 | Poland Europe 1982 71.32 36227381 8451.531004 1233 | Poland Europe 1987 70.98 37740710 9082.351172 1234 | Poland Europe 1992 70.99 38370697 7738.881247 1235 | Poland Europe 1997 72.75 38654957 10159.58368 1236 | Poland Europe 2002 74.67 38625976 12002.23908 1237 | Poland Europe 2007 75.563 38518241 15389.92468 1238 | Portugal Europe 1952 59.82 8526050 3068.319867 1239 | Portugal Europe 1957 61.51 8817650 3774.571743 1240 | Portugal Europe 1962 64.39 9019800 4727.954889 1241 | Portugal Europe 1967 66.6 9103000 6361.517993 1242 | Portugal Europe 1972 69.26 8970450 9022.247417 1243 | Portugal Europe 1977 70.41 9662600 10172.48572 1244 | Portugal Europe 1982 72.77 9859650 11753.84291 1245 | Portugal Europe 1987 74.06 9915289 13039.30876 1246 | Portugal Europe 1992 74.86 9927680 16207.26663 1247 | Portugal Europe 1997 75.97 10156415 17641.03156 1248 | Portugal Europe 2002 77.29 10433867 19970.90787 1249 | Portugal Europe 2007 78.098 10642836 20509.64777 1250 | Puerto Rico Americas 1952 64.28 2227000 3081.959785 1251 | Puerto Rico Americas 1957 68.54 2260000 3907.156189 1252 | Puerto Rico Americas 1962 69.62 2448046 5108.34463 1253 | Puerto Rico Americas 1967 71.1 2648961 6929.277714 1254 | Puerto Rico Americas 1972 72.16 2847132 9123.041742 1255 | Puerto Rico Americas 1977 73.44 3080828 9770.524921 1256 | Puerto Rico Americas 1982 73.75 3279001 10330.98915 1257 | Puerto Rico Americas 1987 74.63 3444468 12281.34191 1258 | Puerto Rico Americas 1992 73.911 3585176 14641.58711 1259 | Puerto Rico Americas 1997 74.917 3759430 16999.4333 1260 | Puerto Rico Americas 2002 77.778 3859606 18855.60618 1261 | Puerto Rico Americas 2007 78.746 3942491 19328.70901 1262 | Reunion Africa 1952 52.724 257700 2718.885295 1263 | Reunion Africa 1957 55.09 308700 2769.451844 1264 | Reunion Africa 1962 57.666 358900 3173.72334 1265 | Reunion Africa 1967 60.542 414024 4021.175739 1266 | Reunion Africa 1972 64.274 461633 5047.658563 1267 | Reunion Africa 1977 67.064 492095 4319.804067 1268 | Reunion Africa 1982 69.885 517810 5267.219353 1269 | Reunion Africa 1987 71.913 562035 5303.377488 1270 | Reunion Africa 1992 73.615 622191 6101.255823 1271 | Reunion Africa 1997 74.772 684810 6071.941411 1272 | Reunion Africa 2002 75.744 743981 6316.1652 1273 | Reunion Africa 2007 76.442 798094 7670.122558 1274 | Romania Europe 1952 61.05 16630000 3144.613186 1275 | Romania Europe 1957 64.1 17829327 3943.370225 1276 | Romania Europe 1962 66.8 18680721 4734.997586 1277 | Romania Europe 1967 66.8 19284814 6470.866545 1278 | Romania Europe 1972 69.21 20662648 8011.414402 1279 | Romania Europe 1977 69.46 21658597 9356.39724 1280 | Romania Europe 1982 69.66 22356726 9605.314053 1281 | Romania Europe 1987 69.53 22686371 9696.273295 1282 | Romania Europe 1992 69.36 22797027 6598.409903 1283 | Romania Europe 1997 69.72 22562458 7346.547557 1284 | Romania Europe 2002 71.322 22404337 7885.360081 1285 | Romania Europe 2007 72.476 22276056 10808.47561 1286 | Rwanda Africa 1952 40 2534927 493.3238752 1287 | Rwanda Africa 1957 41.5 2822082 540.2893983 1288 | Rwanda Africa 1962 43 3051242 597.4730727 1289 | Rwanda Africa 1967 44.1 3451079 510.9637142 1290 | Rwanda Africa 1972 44.6 3992121 590.5806638 1291 | Rwanda Africa 1977 45 4657072 670.0806011 1292 | Rwanda Africa 1982 46.218 5507565 881.5706467 1293 | Rwanda Africa 1987 44.02 6349365 847.991217 1294 | Rwanda Africa 1992 23.599 7290203 737.0685949 1295 | Rwanda Africa 1997 36.087 7212583 589.9445051 1296 | Rwanda Africa 2002 43.413 7852401 785.6537648 1297 | Rwanda Africa 2007 46.242 8860588 863.0884639 1298 | Sao Tome and Principe Africa 1952 46.471 60011 879.5835855 1299 | Sao Tome and Principe Africa 1957 48.945 61325 860.7369026 1300 | Sao Tome and Principe Africa 1962 51.893 65345 1071.551119 1301 | Sao Tome and Principe Africa 1967 54.425 70787 1384.840593 1302 | Sao Tome and Principe Africa 1972 56.48 76595 1532.985254 1303 | Sao Tome and Principe Africa 1977 58.55 86796 1737.561657 1304 | Sao Tome and Principe Africa 1982 60.351 98593 1890.218117 1305 | Sao Tome and Principe Africa 1987 61.728 110812 1516.525457 1306 | Sao Tome and Principe Africa 1992 62.742 125911 1428.777814 1307 | Sao Tome and Principe Africa 1997 63.306 145608 1339.076036 1308 | Sao Tome and Principe Africa 2002 64.337 170372 1353.09239 1309 | Sao Tome and Principe Africa 2007 65.528 199579 1598.435089 1310 | Saudi Arabia Asia 1952 39.875 4005677 6459.554823 1311 | Saudi Arabia Asia 1957 42.868 4419650 8157.591248 1312 | Saudi Arabia Asia 1962 45.914 4943029 11626.41975 1313 | Saudi Arabia Asia 1967 49.901 5618198 16903.04886 1314 | Saudi Arabia Asia 1972 53.886 6472756 24837.42865 1315 | Saudi Arabia Asia 1977 58.69 8128505 34167.7626 1316 | Saudi Arabia Asia 1982 63.012 11254672 33693.17525 1317 | Saudi Arabia Asia 1987 66.295 14619745 21198.26136 1318 | Saudi Arabia Asia 1992 68.768 16945857 24841.61777 1319 | Saudi Arabia Asia 1997 70.533 21229759 20586.69019 1320 | Saudi Arabia Asia 2002 71.626 24501530 19014.54118 1321 | Saudi Arabia Asia 2007 72.777 27601038 21654.83194 1322 | Senegal Africa 1952 37.278 2755589 1450.356983 1323 | Senegal Africa 1957 39.329 3054547 1567.653006 1324 | Senegal Africa 1962 41.454 3430243 1654.988723 1325 | Senegal Africa 1967 43.563 3965841 1612.404632 1326 | Senegal Africa 1972 45.815 4588696 1597.712056 1327 | Senegal Africa 1977 48.879 5260855 1561.769116 1328 | Senegal Africa 1982 52.379 6147783 1518.479984 1329 | Senegal Africa 1987 55.769 7171347 1441.72072 1330 | Senegal Africa 1992 58.196 8307920 1367.899369 1331 | Senegal Africa 1997 60.187 9535314 1392.368347 1332 | Senegal Africa 2002 61.6 10870037 1519.635262 1333 | Senegal Africa 2007 63.062 12267493 1712.472136 1334 | Serbia Europe 1952 57.996 6860147 3581.459448 1335 | Serbia Europe 1957 61.685 7271135 4981.090891 1336 | Serbia Europe 1962 64.531 7616060 6289.629157 1337 | Serbia Europe 1967 66.914 7971222 7991.707066 1338 | Serbia Europe 1972 68.7 8313288 10522.06749 1339 | Serbia Europe 1977 70.3 8686367 12980.66956 1340 | Serbia Europe 1982 70.162 9032824 15181.0927 1341 | Serbia Europe 1987 71.218 9230783 15870.87851 1342 | Serbia Europe 1992 71.659 9826397 9325.068238 1343 | Serbia Europe 1997 72.232 10336594 7914.320304 1344 | Serbia Europe 2002 73.213 10111559 7236.075251 1345 | Serbia Europe 2007 74.002 10150265 9786.534714 1346 | Sierra Leone Africa 1952 30.331 2143249 879.7877358 1347 | Sierra Leone Africa 1957 31.57 2295678 1004.484437 1348 | Sierra Leone Africa 1962 32.767 2467895 1116.639877 1349 | Sierra Leone Africa 1967 34.113 2662190 1206.043465 1350 | Sierra Leone Africa 1972 35.4 2879013 1353.759762 1351 | Sierra Leone Africa 1977 36.788 3140897 1348.285159 1352 | Sierra Leone Africa 1982 38.445 3464522 1465.010784 1353 | Sierra Leone Africa 1987 40.006 3868905 1294.447788 1354 | Sierra Leone Africa 1992 38.333 4260884 1068.696278 1355 | Sierra Leone Africa 1997 39.897 4578212 574.6481576 1356 | Sierra Leone Africa 2002 41.012 5359092 699.489713 1357 | Sierra Leone Africa 2007 42.568 6144562 862.5407561 1358 | Singapore Asia 1952 60.396 1127000 2315.138227 1359 | Singapore Asia 1957 63.179 1445929 2843.104409 1360 | Singapore Asia 1962 65.798 1750200 3674.735572 1361 | Singapore Asia 1967 67.946 1977600 4977.41854 1362 | Singapore Asia 1972 69.521 2152400 8597.756202 1363 | Singapore Asia 1977 70.795 2325300 11210.08948 1364 | Singapore Asia 1982 71.76 2651869 15169.16112 1365 | Singapore Asia 1987 73.56 2794552 18861.53081 1366 | Singapore Asia 1992 75.788 3235865 24769.8912 1367 | Singapore Asia 1997 77.158 3802309 33519.4766 1368 | Singapore Asia 2002 78.77 4197776 36023.1054 1369 | Singapore Asia 2007 79.972 4553009 47143.17964 1370 | Slovak Republic Europe 1952 64.36 3558137 5074.659104 1371 | Slovak Republic Europe 1957 67.45 3844277 6093.26298 1372 | Slovak Republic Europe 1962 70.33 4237384 7481.107598 1373 | Slovak Republic Europe 1967 70.98 4442238 8412.902397 1374 | Slovak Republic Europe 1972 70.35 4593433 9674.167626 1375 | Slovak Republic Europe 1977 70.45 4827803 10922.66404 1376 | Slovak Republic Europe 1982 70.8 5048043 11348.54585 1377 | Slovak Republic Europe 1987 71.08 5199318 12037.26758 1378 | Slovak Republic Europe 1992 71.38 5302888 9498.467723 1379 | Slovak Republic Europe 1997 72.71 5383010 12126.23065 1380 | Slovak Republic Europe 2002 73.8 5410052 13638.77837 1381 | Slovak Republic Europe 2007 74.663 5447502 18678.31435 1382 | Slovenia Europe 1952 65.57 1489518 4215.041741 1383 | Slovenia Europe 1957 67.85 1533070 5862.276629 1384 | Slovenia Europe 1962 69.15 1582962 7402.303395 1385 | Slovenia Europe 1967 69.18 1646912 9405.489397 1386 | Slovenia Europe 1972 69.82 1694510 12383.4862 1387 | Slovenia Europe 1977 70.97 1746919 15277.03017 1388 | Slovenia Europe 1982 71.063 1861252 17866.72175 1389 | Slovenia Europe 1987 72.25 1945870 18678.53492 1390 | Slovenia Europe 1992 73.64 1999210 14214.71681 1391 | Slovenia Europe 1997 75.13 2011612 17161.10735 1392 | Slovenia Europe 2002 76.66 2011497 20660.01936 1393 | Slovenia Europe 2007 77.926 2009245 25768.25759 1394 | Somalia Africa 1952 32.978 2526994 1135.749842 1395 | Somalia Africa 1957 34.977 2780415 1258.147413 1396 | Somalia Africa 1962 36.981 3080153 1369.488336 1397 | Somalia Africa 1967 38.977 3428839 1284.73318 1398 | Somalia Africa 1972 40.973 3840161 1254.576127 1399 | Somalia Africa 1977 41.974 4353666 1450.992513 1400 | Somalia Africa 1982 42.955 5828892 1176.807031 1401 | Somalia Africa 1987 44.501 6921858 1093.244963 1402 | Somalia Africa 1992 39.658 6099799 926.9602964 1403 | Somalia Africa 1997 43.795 6633514 930.5964284 1404 | Somalia Africa 2002 45.936 7753310 882.0818218 1405 | Somalia Africa 2007 48.159 9118773 926.1410683 1406 | South Africa Africa 1952 45.009 14264935 4725.295531 1407 | South Africa Africa 1957 47.985 16151549 5487.104219 1408 | South Africa Africa 1962 49.951 18356657 5768.729717 1409 | South Africa Africa 1967 51.927 20997321 7114.477971 1410 | South Africa Africa 1972 53.696 23935810 7765.962636 1411 | South Africa Africa 1977 55.527 27129932 8028.651439 1412 | South Africa Africa 1982 58.161 31140029 8568.266228 1413 | South Africa Africa 1987 60.834 35933379 7825.823398 1414 | South Africa Africa 1992 61.888 39964159 7225.069258 1415 | South Africa Africa 1997 60.236 42835005 7479.188244 1416 | South Africa Africa 2002 53.365 44433622 7710.946444 1417 | South Africa Africa 2007 49.339 43997828 9269.657808 1418 | Spain Europe 1952 64.94 28549870 3834.034742 1419 | Spain Europe 1957 66.66 29841614 4564.80241 1420 | Spain Europe 1962 69.69 31158061 5693.843879 1421 | Spain Europe 1967 71.44 32850275 7993.512294 1422 | Spain Europe 1972 73.06 34513161 10638.75131 1423 | Spain Europe 1977 74.39 36439000 13236.92117 1424 | Spain Europe 1982 76.3 37983310 13926.16997 1425 | Spain Europe 1987 76.9 38880702 15764.98313 1426 | Spain Europe 1992 77.57 39549438 18603.06452 1427 | Spain Europe 1997 78.77 39855442 20445.29896 1428 | Spain Europe 2002 79.78 40152517 24835.47166 1429 | Spain Europe 2007 80.941 40448191 28821.0637 1430 | Sri Lanka Asia 1952 57.593 7982342 1083.53203 1431 | Sri Lanka Asia 1957 61.456 9128546 1072.546602 1432 | Sri Lanka Asia 1962 62.192 10421936 1074.47196 1433 | Sri Lanka Asia 1967 64.266 11737396 1135.514326 1434 | Sri Lanka Asia 1972 65.042 13016733 1213.39553 1435 | Sri Lanka Asia 1977 65.949 14116836 1348.775651 1436 | Sri Lanka Asia 1982 68.757 15410151 1648.079789 1437 | Sri Lanka Asia 1987 69.011 16495304 1876.766827 1438 | Sri Lanka Asia 1992 70.379 17587060 2153.739222 1439 | Sri Lanka Asia 1997 70.457 18698655 2664.477257 1440 | Sri Lanka Asia 2002 70.815 19576783 3015.378833 1441 | Sri Lanka Asia 2007 72.396 20378239 3970.095407 1442 | Sudan Africa 1952 38.635 8504667 1615.991129 1443 | Sudan Africa 1957 39.624 9753392 1770.337074 1444 | Sudan Africa 1962 40.87 11183227 1959.593767 1445 | Sudan Africa 1967 42.858 12716129 1687.997641 1446 | Sudan Africa 1972 45.083 14597019 1659.652775 1447 | Sudan Africa 1977 47.8 17104986 2202.988423 1448 | Sudan Africa 1982 50.338 20367053 1895.544073 1449 | Sudan Africa 1987 51.744 24725960 1507.819159 1450 | Sudan Africa 1992 53.556 28227588 1492.197043 1451 | Sudan Africa 1997 55.373 32160729 1632.210764 1452 | Sudan Africa 2002 56.369 37090298 1993.398314 1453 | Sudan Africa 2007 58.556 42292929 2602.394995 1454 | Swaziland Africa 1952 41.407 290243 1148.376626 1455 | Swaziland Africa 1957 43.424 326741 1244.708364 1456 | Swaziland Africa 1962 44.992 370006 1856.182125 1457 | Swaziland Africa 1967 46.633 420690 2613.101665 1458 | Swaziland Africa 1972 49.552 480105 3364.836625 1459 | Swaziland Africa 1977 52.537 551425 3781.410618 1460 | Swaziland Africa 1982 55.561 649901 3895.384018 1461 | Swaziland Africa 1987 57.678 779348 3984.839812 1462 | Swaziland Africa 1992 58.474 962344 3553.0224 1463 | Swaziland Africa 1997 54.289 1054486 3876.76846 1464 | Swaziland Africa 2002 43.869 1130269 4128.116943 1465 | Swaziland Africa 2007 39.613 1133066 4513.480643 1466 | Sweden Europe 1952 71.86 7124673 8527.844662 1467 | Sweden Europe 1957 72.49 7363802 9911.878226 1468 | Sweden Europe 1962 73.37 7561588 12329.44192 1469 | Sweden Europe 1967 74.16 7867931 15258.29697 1470 | Sweden Europe 1972 74.72 8122293 17832.02464 1471 | Sweden Europe 1977 75.44 8251648 18855.72521 1472 | Sweden Europe 1982 76.42 8325260 20667.38125 1473 | Sweden Europe 1987 77.19 8421403 23586.92927 1474 | Sweden Europe 1992 78.16 8718867 23880.01683 1475 | Sweden Europe 1997 79.39 8897619 25266.59499 1476 | Sweden Europe 2002 80.04 8954175 29341.63093 1477 | Sweden Europe 2007 80.884 9031088 33859.74835 1478 | Switzerland Europe 1952 69.62 4815000 14734.23275 1479 | Switzerland Europe 1957 70.56 5126000 17909.48973 1480 | Switzerland Europe 1962 71.32 5666000 20431.0927 1481 | Switzerland Europe 1967 72.77 6063000 22966.14432 1482 | Switzerland Europe 1972 73.78 6401400 27195.11304 1483 | Switzerland Europe 1977 75.39 6316424 26982.29052 1484 | Switzerland Europe 1982 76.21 6468126 28397.71512 1485 | Switzerland Europe 1987 77.41 6649942 30281.70459 1486 | Switzerland Europe 1992 78.03 6995447 31871.5303 1487 | Switzerland Europe 1997 79.37 7193761 32135.32301 1488 | Switzerland Europe 2002 80.62 7361757 34480.95771 1489 | Switzerland Europe 2007 81.701 7554661 37506.41907 1490 | Syria Asia 1952 45.883 3661549 1643.485354 1491 | Syria Asia 1957 48.284 4149908 2117.234893 1492 | Syria Asia 1962 50.305 4834621 2193.037133 1493 | Syria Asia 1967 53.655 5680812 1881.923632 1494 | Syria Asia 1972 57.296 6701172 2571.423014 1495 | Syria Asia 1977 61.195 7932503 3195.484582 1496 | Syria Asia 1982 64.59 9410494 3761.837715 1497 | Syria Asia 1987 66.974 11242847 3116.774285 1498 | Syria Asia 1992 69.249 13219062 3340.542768 1499 | Syria Asia 1997 71.527 15081016 4014.238972 1500 | Syria Asia 2002 73.053 17155814 4090.925331 1501 | Syria Asia 2007 74.143 19314747 4184.548089 1502 | Taiwan Asia 1952 58.5 8550362 1206.947913 1503 | Taiwan Asia 1957 62.4 10164215 1507.86129 1504 | Taiwan Asia 1962 65.2 11918938 1822.879028 1505 | Taiwan Asia 1967 67.5 13648692 2643.858681 1506 | Taiwan Asia 1972 69.39 15226039 4062.523897 1507 | Taiwan Asia 1977 70.59 16785196 5596.519826 1508 | Taiwan Asia 1982 72.16 18501390 7426.354774 1509 | Taiwan Asia 1987 73.4 19757799 11054.56175 1510 | Taiwan Asia 1992 74.26 20686918 15215.6579 1511 | Taiwan Asia 1997 75.25 21628605 20206.82098 1512 | Taiwan Asia 2002 76.99 22454239 23235.42329 1513 | Taiwan Asia 2007 78.4 23174294 28718.27684 1514 | Tanzania Africa 1952 41.215 8322925 716.6500721 1515 | Tanzania Africa 1957 42.974 9452826 698.5356073 1516 | Tanzania Africa 1962 44.246 10863958 722.0038073 1517 | Tanzania Africa 1967 45.757 12607312 848.2186575 1518 | Tanzania Africa 1972 47.62 14706593 915.9850592 1519 | Tanzania Africa 1977 49.919 17129565 962.4922932 1520 | Tanzania Africa 1982 50.608 19844382 874.2426069 1521 | Tanzania Africa 1987 51.535 23040630 831.8220794 1522 | Tanzania Africa 1992 50.44 26605473 825.682454 1523 | Tanzania Africa 1997 48.466 30686889 789.1862231 1524 | Tanzania Africa 2002 49.651 34593779 899.0742111 1525 | Tanzania Africa 2007 52.517 38139640 1107.482182 1526 | Thailand Asia 1952 50.848 21289402 757.7974177 1527 | Thailand Asia 1957 53.63 25041917 793.5774148 1528 | Thailand Asia 1962 56.061 29263397 1002.199172 1529 | Thailand Asia 1967 58.285 34024249 1295.46066 1530 | Thailand Asia 1972 60.405 39276153 1524.358936 1531 | Thailand Asia 1977 62.494 44148285 1961.224635 1532 | Thailand Asia 1982 64.597 48827160 2393.219781 1533 | Thailand Asia 1987 66.084 52910342 2982.653773 1534 | Thailand Asia 1992 67.298 56667095 4616.896545 1535 | Thailand Asia 1997 67.521 60216677 5852.625497 1536 | Thailand Asia 2002 68.564 62806748 5913.187529 1537 | Thailand Asia 2007 70.616 65068149 7458.396327 1538 | Togo Africa 1952 38.596 1219113 859.8086567 1539 | Togo Africa 1957 41.208 1357445 925.9083202 1540 | Togo Africa 1962 43.922 1528098 1067.53481 1541 | Togo Africa 1967 46.769 1735550 1477.59676 1542 | Togo Africa 1972 49.759 2056351 1649.660188 1543 | Togo Africa 1977 52.887 2308582 1532.776998 1544 | Togo Africa 1982 55.471 2644765 1344.577953 1545 | Togo Africa 1987 56.941 3154264 1202.201361 1546 | Togo Africa 1992 58.061 3747553 1034.298904 1547 | Togo Africa 1997 58.39 4320890 982.2869243 1548 | Togo Africa 2002 57.561 4977378 886.2205765 1549 | Togo Africa 2007 58.42 5701579 882.9699438 1550 | Trinidad and Tobago Americas 1952 59.1 662850 3023.271928 1551 | Trinidad and Tobago Americas 1957 61.8 764900 4100.3934 1552 | Trinidad and Tobago Americas 1962 64.9 887498 4997.523971 1553 | Trinidad and Tobago Americas 1967 65.4 960155 5621.368472 1554 | Trinidad and Tobago Americas 1972 65.9 975199 6619.551419 1555 | Trinidad and Tobago Americas 1977 68.3 1039009 7899.554209 1556 | Trinidad and Tobago Americas 1982 68.832 1116479 9119.528607 1557 | Trinidad and Tobago Americas 1987 69.582 1191336 7388.597823 1558 | Trinidad and Tobago Americas 1992 69.862 1183669 7370.990932 1559 | Trinidad and Tobago Americas 1997 69.465 1138101 8792.573126 1560 | Trinidad and Tobago Americas 2002 68.976 1101832 11460.60023 1561 | Trinidad and Tobago Americas 2007 69.819 1056608 18008.50924 1562 | Tunisia Africa 1952 44.6 3647735 1468.475631 1563 | Tunisia Africa 1957 47.1 3950849 1395.232468 1564 | Tunisia Africa 1962 49.579 4286552 1660.30321 1565 | Tunisia Africa 1967 52.053 4786986 1932.360167 1566 | Tunisia Africa 1972 55.602 5303507 2753.285994 1567 | Tunisia Africa 1977 59.837 6005061 3120.876811 1568 | Tunisia Africa 1982 64.048 6734098 3560.233174 1569 | Tunisia Africa 1987 66.894 7724976 3810.419296 1570 | Tunisia Africa 1992 70.001 8523077 4332.720164 1571 | Tunisia Africa 1997 71.973 9231669 4876.798614 1572 | Tunisia Africa 2002 73.042 9770575 5722.895655 1573 | Tunisia Africa 2007 73.923 10276158 7092.923025 1574 | Turkey Europe 1952 43.585 22235677 1969.10098 1575 | Turkey Europe 1957 48.079 25670939 2218.754257 1576 | Turkey Europe 1962 52.098 29788695 2322.869908 1577 | Turkey Europe 1967 54.336 33411317 2826.356387 1578 | Turkey Europe 1972 57.005 37492953 3450.69638 1579 | Turkey Europe 1977 59.507 42404033 4269.122326 1580 | Turkey Europe 1982 61.036 47328791 4241.356344 1581 | Turkey Europe 1987 63.108 52881328 5089.043686 1582 | Turkey Europe 1992 66.146 58179144 5678.348271 1583 | Turkey Europe 1997 68.835 63047647 6601.429915 1584 | Turkey Europe 2002 70.845 67308928 6508.085718 1585 | Turkey Europe 2007 71.777 71158647 8458.276384 1586 | Uganda Africa 1952 39.978 5824797 734.753484 1587 | Uganda Africa 1957 42.571 6675501 774.3710692 1588 | Uganda Africa 1962 45.344 7688797 767.2717398 1589 | Uganda Africa 1967 48.051 8900294 908.9185217 1590 | Uganda Africa 1972 51.016 10190285 950.735869 1591 | Uganda Africa 1977 50.35 11457758 843.7331372 1592 | Uganda Africa 1982 49.849 12939400 682.2662268 1593 | Uganda Africa 1987 51.509 15283050 617.7244065 1594 | Uganda Africa 1992 48.825 18252190 644.1707969 1595 | Uganda Africa 1997 44.578 21210254 816.559081 1596 | Uganda Africa 2002 47.813 24739869 927.7210018 1597 | Uganda Africa 2007 51.542 29170398 1056.380121 1598 | United Kingdom Europe 1952 69.18 50430000 9979.508487 1599 | United Kingdom Europe 1957 70.42 51430000 11283.17795 1600 | United Kingdom Europe 1962 70.76 53292000 12477.17707 1601 | United Kingdom Europe 1967 71.36 54959000 14142.85089 1602 | United Kingdom Europe 1972 72.01 56079000 15895.11641 1603 | United Kingdom Europe 1977 72.76 56179000 17428.74846 1604 | United Kingdom Europe 1982 74.04 56339704 18232.42452 1605 | United Kingdom Europe 1987 75.007 56981620 21664.78767 1606 | United Kingdom Europe 1992 76.42 57866349 22705.09254 1607 | United Kingdom Europe 1997 77.218 58808266 26074.53136 1608 | United Kingdom Europe 2002 78.471 59912431 29478.99919 1609 | United Kingdom Europe 2007 79.425 60776238 33203.26128 1610 | United States Americas 1952 68.44 157553000 13990.48208 1611 | United States Americas 1957 69.49 171984000 14847.12712 1612 | United States Americas 1962 70.21 186538000 16173.14586 1613 | United States Americas 1967 70.76 198712000 19530.36557 1614 | United States Americas 1972 71.34 209896000 21806.03594 1615 | United States Americas 1977 73.38 220239000 24072.63213 1616 | United States Americas 1982 74.65 232187835 25009.55914 1617 | United States Americas 1987 75.02 242803533 29884.35041 1618 | United States Americas 1992 76.09 256894189 32003.93224 1619 | United States Americas 1997 76.81 272911760 35767.43303 1620 | United States Americas 2002 77.31 287675526 39097.09955 1621 | United States Americas 2007 78.242 301139947 42951.65309 1622 | Uruguay Americas 1952 66.071 2252965 5716.766744 1623 | Uruguay Americas 1957 67.044 2424959 6150.772969 1624 | Uruguay Americas 1962 68.253 2598466 5603.357717 1625 | Uruguay Americas 1967 68.468 2748579 5444.61962 1626 | Uruguay Americas 1972 68.673 2829526 5703.408898 1627 | Uruguay Americas 1977 69.481 2873520 6504.339663 1628 | Uruguay Americas 1982 70.805 2953997 6920.223051 1629 | Uruguay Americas 1987 71.918 3045153 7452.398969 1630 | Uruguay Americas 1992 72.752 3149262 8137.004775 1631 | Uruguay Americas 1997 74.223 3262838 9230.240708 1632 | Uruguay Americas 2002 75.307 3363085 7727.002004 1633 | Uruguay Americas 2007 76.384 3447496 10611.46299 1634 | Venezuela Americas 1952 55.088 5439568 7689.799761 1635 | Venezuela Americas 1957 57.907 6702668 9802.466526 1636 | Venezuela Americas 1962 60.77 8143375 8422.974165 1637 | Venezuela Americas 1967 63.479 9709552 9541.474188 1638 | Venezuela Americas 1972 65.712 11515649 10505.25966 1639 | Venezuela Americas 1977 67.456 13503563 13143.95095 1640 | Venezuela Americas 1982 68.557 15620766 11152.41011 1641 | Venezuela Americas 1987 70.19 17910182 9883.584648 1642 | Venezuela Americas 1992 71.15 20265563 10733.92631 1643 | Venezuela Americas 1997 72.146 22374398 10165.49518 1644 | Venezuela Americas 2002 72.766 24287670 8605.047831 1645 | Venezuela Americas 2007 73.747 26084662 11415.80569 1646 | Vietnam Asia 1952 40.412 26246839 605.0664917 1647 | Vietnam Asia 1957 42.887 28998543 676.2854478 1648 | Vietnam Asia 1962 45.363 33796140 772.0491602 1649 | Vietnam Asia 1967 47.838 39463910 637.1232887 1650 | Vietnam Asia 1972 50.254 44655014 699.5016441 1651 | Vietnam Asia 1977 55.764 50533506 713.5371196 1652 | Vietnam Asia 1982 58.816 56142181 707.2357863 1653 | Vietnam Asia 1987 62.82 62826491 820.7994449 1654 | Vietnam Asia 1992 67.662 69940728 989.0231487 1655 | Vietnam Asia 1997 70.672 76048996 1385.896769 1656 | Vietnam Asia 2002 73.017 80908147 1764.456677 1657 | Vietnam Asia 2007 74.249 85262356 2441.576404 1658 | West Bank and Gaza Asia 1952 43.16 1030585 1515.592329 1659 | West Bank and Gaza Asia 1957 45.671 1070439 1827.067742 1660 | West Bank and Gaza Asia 1962 48.127 1133134 2198.956312 1661 | West Bank and Gaza Asia 1967 51.631 1142636 2649.715007 1662 | West Bank and Gaza Asia 1972 56.532 1089572 3133.409277 1663 | West Bank and Gaza Asia 1977 60.765 1261091 3682.831494 1664 | West Bank and Gaza Asia 1982 64.406 1425876 4336.032082 1665 | West Bank and Gaza Asia 1987 67.046 1691210 5107.197384 1666 | West Bank and Gaza Asia 1992 69.718 2104779 6017.654756 1667 | West Bank and Gaza Asia 1997 71.096 2826046 7110.667619 1668 | West Bank and Gaza Asia 2002 72.37 3389578 4515.487575 1669 | West Bank and Gaza Asia 2007 73.422 4018332 3025.349798 1670 | Yemen, Rep. Asia 1952 32.548 4963829 781.7175761 1671 | Yemen, Rep. Asia 1957 33.97 5498090 804.8304547 1672 | Yemen, Rep. Asia 1962 35.18 6120081 825.6232006 1673 | Yemen, Rep. Asia 1967 36.984 6740785 862.4421463 1674 | Yemen, Rep. Asia 1972 39.848 7407075 1265.047031 1675 | Yemen, Rep. Asia 1977 44.175 8403990 1829.765177 1676 | Yemen, Rep. Asia 1982 49.113 9657618 1977.55701 1677 | Yemen, Rep. Asia 1987 52.922 11219340 1971.741538 1678 | Yemen, Rep. Asia 1992 55.599 13367997 1879.496673 1679 | Yemen, Rep. Asia 1997 58.02 15826497 2117.484526 1680 | Yemen, Rep. Asia 2002 60.308 18701257 2234.820827 1681 | Yemen, Rep. Asia 2007 62.698 22211743 2280.769906 1682 | Zambia Africa 1952 42.038 2672000 1147.388831 1683 | Zambia Africa 1957 44.077 3016000 1311.956766 1684 | Zambia Africa 1962 46.023 3421000 1452.725766 1685 | Zambia Africa 1967 47.768 3900000 1777.077318 1686 | Zambia Africa 1972 50.107 4506497 1773.498265 1687 | Zambia Africa 1977 51.386 5216550 1588.688299 1688 | Zambia Africa 1982 51.821 6100407 1408.678565 1689 | Zambia Africa 1987 50.821 7272406 1213.315116 1690 | Zambia Africa 1992 46.1 8381163 1210.884633 1691 | Zambia Africa 1997 40.238 9417789 1071.353818 1692 | Zambia Africa 2002 39.193 10595811 1071.613938 1693 | Zambia Africa 2007 42.384 11746035 1271.211593 1694 | Zimbabwe Africa 1952 48.451 3080907 406.8841148 1695 | Zimbabwe Africa 1957 50.469 3646340 518.7642681 1696 | Zimbabwe Africa 1962 52.358 4277736 527.2721818 1697 | Zimbabwe Africa 1967 53.995 4995432 569.7950712 1698 | Zimbabwe Africa 1972 55.635 5861135 799.3621758 1699 | Zimbabwe Africa 1977 57.674 6642107 685.5876821 1700 | Zimbabwe Africa 1982 60.363 7636524 788.8550411 1701 | Zimbabwe Africa 1987 62.351 9216418 706.1573059 1702 | Zimbabwe Africa 1992 60.377 10704340 693.4207856 1703 | Zimbabwe Africa 1997 46.809 11404948 792.4499603 1704 | Zimbabwe Africa 2002 39.989 11926563 672.0386227 1705 | Zimbabwe Africa 2007 43.487 12311143 469.7092981 1706 | --------------------------------------------------------------------------------