{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Demo: Exploring the Iris Dataset\n", "\n", "We'll start this tutorial with a demo to whet your appetite for learning more. This section purposely moves quickly through many of the concepts (e.g. data, marks, encodings, aggregation, data types, selections, etc.)\n", "We will return to treat each of these in more depth later in the tutorial, so don't worry if it all seems to go a bit quickly!\n", "\n", "In the live tutorial, this will be done from scratch in a blank notebook.\n", "However, for the sake of people who want to look back on what we did live, I'll do my best to reproduce the examples and the discussion here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Imports and Data\n", "\n", "We'll start with importing the [Altair package](http://altair-viz.github.io/) and enabling the appropriate renderer (if necessary):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import altair as alt\n", "\n", "# Altair plots render by default in JupyterLab and nteract\n", "\n", "# Uncomment/run this line to enable Altair in the classic notebook (not in JupyterLab)\n", "# alt.renderers.enable('notebook')\n", "\n", "# Uncomment/run this line to enable Altair in Colab\n", "# alt.renderers.enable('colab')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we'll use the [vega_datasets package](https://github.com/altair-viz/vega_datasets), to load an example dataset:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | petalLength | \n", "petalWidth | \n", "sepalLength | \n", "sepalWidth | \n", "species | \n", "
---|---|---|---|---|---|
0 | \n", "1.4 | \n", "0.2 | \n", "5.1 | \n", "3.5 | \n", "setosa | \n", "
1 | \n", "1.4 | \n", "0.2 | \n", "4.9 | \n", "3.0 | \n", "setosa | \n", "
2 | \n", "1.3 | \n", "0.2 | \n", "4.7 | \n", "3.2 | \n", "setosa | \n", "
3 | \n", "1.5 | \n", "0.2 | \n", "4.6 | \n", "3.1 | \n", "setosa | \n", "
4 | \n", "1.4 | \n", "0.2 | \n", "5.0 | \n", "3.6 | \n", "setosa | \n", "