{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simple data visualization: the bar chart" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this notebook we'll be comparing as many Python visualization libraries as possible with one simple metric: how easy is it to make a bar chart? We'll also look a bit into customization with each library, and explore the pain points a bit. \n", "\n", "_Note: if you're viewing this on GitHub, charting libraries that output Javascript (Bokeh, Holoviews, Altair) won't display. Try viewing the notebook on [my nbviewer page](http://nbviewer.jupyter.org/github/dovinmu/python-viz-notebooks/tree/master/) instead._\n", "\n", "First, let's load a pandas DataFrame of the data we'll be using and clean it a bit. There's a CSV in the repository that lists over 4,000 cities and towns in the United States. For now, let's just take the cities that are over a certain size and plop that into various charting libraries. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Population | \n", "
|---|---|
| Name | \n", "\n", " |
| Tucson | \n", "0.518907 | \n", "
| Nashville | \n", "0.530852 | \n", "
| Oklahoma City | \n", "0.532950 | \n", "
| Las Vegas | \n", "0.540111 | \n", "
| Portland | \n", "0.540513 | \n", "
| Washington | \n", "0.552433 | \n", "
| Denver | \n", "0.555981 | \n", "
| Seattle | \n", "0.569369 | \n", "
| Boston | \n", "0.571281 | \n", "
| Milwaukee | \n", "0.579180 | \n", "
| El Paso | \n", "0.597181 | \n", "
| Charlotte | \n", "0.598351 | \n", "
| Baltimore | \n", "0.610892 | \n", "
| Fort Worth | \n", "0.618119 | \n", "
| Memphis | \n", "0.641608 | \n", "
| Austin | \n", "0.678368 | \n", "
| San Francisco | \n", "0.732072 | \n", "
| Columbus | \n", "0.736836 | \n", "
| Indianapolis | \n", "0.773283 | \n", "
| Jacksonville | \n", "0.797557 | \n", "
| Detroit | \n", "0.884941 | \n", "
| San Jose | \n", "0.897460 | \n", "
| Dallas | \n", "1.211704 | \n", "
| San Antonio | \n", "1.256810 | \n", "
| San Diego | \n", "1.287050 | \n", "
| Phoenix | \n", "1.428509 | \n", "
| Philadelphia | \n", "1.453268 | \n", "
| Houston | \n", "2.027712 | \n", "
| Chicago | \n", "2.841952 | \n", "
| Los Angeles | \n", "3.877129 | \n", "
| New York | \n", "8.107916 | \n", "
\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"\\n\"+\n",
" \"\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"