<html lang="en"> <head> <title>Untitled</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="https://unpkg.com/@stencila/thema@2/dist/themes/stencila/styles.css" rel="stylesheet"> <script src="https://unpkg.com/@stencila/thema@2/dist/themes/stencila/index.js" type="text/javascript"></script> <script src="https://unpkg.com/@stencila/components@<=1/dist/stencila-components/stencila-components.esm.js" type="module"></script> <script src="https://unpkg.com/@stencila/components@<=1/dist/stencila-components/stencila-components.js" type="text/javascript" nomodule=""></script> </head> <body> <main role="main"> <article itemscope="" itemtype="http://schema.org/Article" data-itemscope="root"> <meta itemprop="image" content="https://via.placeholder.com/1200x714/dbdbdb/4a4a4a.png?text="><span itemscope="" itemtype="http://schema.org/Organization" itemprop="publisher"> <meta itemprop="name" content="Unknown"><span itemscope="" itemtype="http://schema.org/ImageObject" itemprop="logo"> <meta itemprop="url" content="https://via.placeholder.com/600x60/dbdbdb/4a4a4a.png?text=Unknown"> </span> </span> <h3 itemscope="" itemtype="http://schema.stenci.la/Heading" id="develop-an-interactive-visualisation-with-altair">Develop an interactive visualisation with altair</h3> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" id="RDwrboyB_NaU"> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-execution_count="16" data-programminglanguage="python"> <pre class="language-python" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>import pandas as pd import numpy as np import altair as alt</code></pre> </stencila-code-chunk> </figure> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" id="yurcBAFo_uZK"> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-colab="[object Object]" data-outputid="c919d04d-ff59-4ca7-fafa-ff4c1f4705f3" data-execution_count="2" data-programminglanguage="python"> <pre class="language-python" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>url = "https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv" cars = pd.read_csv(url) cars.head()</code></pre> <figure slot="outputs"> <table itemscope="" itemtype="http://schema.org/Table"> <thead> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <th itemscope="" itemtype="http://schema.stenci.la/TableCell"></th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">model</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">mpg</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">cyl</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">disp</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">hp</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">drat</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">wt</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">qsec</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">vs</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">am</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">gear</th> <th itemscope="" itemtype="http://schema.stenci.la/TableCell">carb</th> </tr> </thead> <tbody> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell">Mazda RX4</td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">21</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">6</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">160</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">110</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.9</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">2.62</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">16.46</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> </tr> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell">Mazda RX4 Wag</td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">21</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">6</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">160</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">110</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.9</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">2.875</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">17.02</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> </tr> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">2</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell">Datsun 710</td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">22.8</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">108</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">93</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.85</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">2.32</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">18.61</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> </tr> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell">Hornet 4 Drive </td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">21.4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">6</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">258</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">110</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.08</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.215</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">19.44</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">1</span></td> </tr> <tr itemscope="" itemtype="http://schema.stenci.la/TableRow"> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">4</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell">Hornet Sportabout </td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">18.7</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">8</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">360</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">175</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.15</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3.44</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">17.02</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">0</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">3</span></td> <td itemscope="" itemtype="http://schema.stenci.la/TableCell"><span data-itemtype="http://schema.org/Number">2</span></td> </tr> </tbody> </table> </figure> </stencila-code-chunk> </figure> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" id="JJHXj8RQAKEG"> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-colab="[object Object]" data-outputid="f6bfcc2e-af79-4e6a-e577-c9632bb37f28" data-execution_count="15" data-programminglanguage="python"> <pre class="language-python" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code>chart = alt.Chart(cars) cars_chart = chart.mark_point().encode( x = 'wt:Q', y = 'mpg:Q' ) cars_chart</code></pre> <figure slot="outputs"><span data-itemtype="http://schema.stenci.la/Null">null</span> </figure> </stencila-code-chunk> </figure> <figure itemscope="" itemtype="http://schema.stenci.la/Figure" id="ZxQvRYzTAh47"> <stencila-code-chunk itemscope="" itemtype="http://schema.stenci.la/CodeChunk" data-execution_count="null" data-programminglanguage="python"> <pre class="language-python" itemscope="" itemtype="http://schema.stenci.la/CodeBlock" slot="text"><code></code></pre> </stencila-code-chunk> </figure> </article> </main> </body> </html>