{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Quantitative comparisons and statistical visualizations\n", "> Visualizations can be used to compare data in a quantitative manner. This chapter explains several methods for quantitative visualizations. This is the Summary of lecture \"Introduction to Data Visualization with Matplotlib\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Visualization]\n", "- image: images/medals_country.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rcParams['figure.figsize'] = (10, 5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quantitative comparisons: bar-charts\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Bar chart\n", "Bar charts visualize data that is organized according to categories as a series of bars, where the height of each bar represents the values of the data in this category.\n", "\n", "For example, in this exercise, you will visualize the number of gold medals won by each country in the provided `medals` DataFrame. The DataFrame contains the countries as the index, and a column called \"Gold\" that contains the number of gold medals won by each country, according to their rows." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Bronze | \n", "Gold | \n", "Silver | \n", "
---|---|---|---|
United States | \n", "67 | \n", "137 | \n", "52 | \n", "
Germany | \n", "67 | \n", "47 | \n", "43 | \n", "
Great Britain | \n", "26 | \n", "64 | \n", "55 | \n", "
Russia | \n", "35 | \n", "50 | \n", "28 | \n", "
China | \n", "35 | \n", "44 | \n", "30 | \n", "
France | \n", "21 | \n", "20 | \n", "55 | \n", "
Australia | \n", "25 | \n", "23 | \n", "34 | \n", "
Italy | \n", "24 | \n", "8 | \n", "38 | \n", "
Canada | \n", "61 | \n", "4 | \n", "4 | \n", "
Japan | \n", "34 | \n", "17 | \n", "13 | \n", "