Skip to content

Commit

Permalink
Auto-commit: Mon Oct 28 12:39:29 CDT 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
jnaiman committed Oct 28, 2024
1 parent ad1667d commit 747afc5
Showing 1 changed file with 89 additions and 3 deletions.
92 changes: 89 additions & 3 deletions week10/inClass_week10.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,97 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "038068f8",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/html": [
"\n",
"<style>\n",
" #altair-viz-41089e6aa08c4da19b7716373b179ec8.vega-embed {\n",
" width: 100%;\n",
" display: flex;\n",
" }\n",
"\n",
" #altair-viz-41089e6aa08c4da19b7716373b179ec8.vega-embed details,\n",
" #altair-viz-41089e6aa08c4da19b7716373b179ec8.vega-embed details summary {\n",
" position: relative;\n",
" }\n",
"</style>\n",
"<div id=\"altair-viz-41089e6aa08c4da19b7716373b179ec8\"></div>\n",
"<script type=\"text/javascript\">\n",
" var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n",
" (function(spec, embedOpt){\n",
" let outputDiv = document.currentScript.previousElementSibling;\n",
" if (outputDiv.id !== \"altair-viz-41089e6aa08c4da19b7716373b179ec8\") {\n",
" outputDiv = document.getElementById(\"altair-viz-41089e6aa08c4da19b7716373b179ec8\");\n",
" }\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm/vega@5?noext\",\n",
" \"vega-lib\": \"https://cdn.jsdelivr.net/npm/vega-lib?noext\",\n",
" \"vega-lite\": \"https://cdn.jsdelivr.net/npm/vega-lite@5.20.1?noext\",\n",
" \"vega-embed\": \"https://cdn.jsdelivr.net/npm/vega-embed@6?noext\",\n",
" };\n",
"\n",
" function maybeLoadScript(lib, version) {\n",
" var key = `${lib.replace(\"-\", \"\")}_version`;\n",
" return (VEGA_DEBUG[key] == version) ?\n",
" Promise.resolve(paths[lib]) :\n",
" new Promise(function(resolve, reject) {\n",
" var s = document.createElement('script');\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" s.async = true;\n",
" s.onload = () => {\n",
" VEGA_DEBUG[key] = version;\n",
" return resolve(paths[lib]);\n",
" };\n",
" s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n",
" s.src = paths[lib];\n",
" });\n",
" }\n",
"\n",
" function showError(err) {\n",
" outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n",
" throw err;\n",
" }\n",
"\n",
" function displayChart(vegaEmbed) {\n",
" vegaEmbed(outputDiv, spec, embedOpt)\n",
" .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n",
" }\n",
"\n",
" if(typeof define === \"function\" && define.amd) {\n",
" requirejs.config({paths});\n",
" require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
" } else {\n",
" maybeLoadScript(\"vega\", \"5\")\n",
" .then(() => maybeLoadScript(\"vega-lite\", \"5.20.1\"))\n",
" .then(() => maybeLoadScript(\"vega-embed\", \"6\"))\n",
" .catch(showError)\n",
" .then(() => displayChart(vegaEmbed));\n",
" }\n",
" })({\"config\": {\"view\": {\"continuousWidth\": 300, \"continuousHeight\": 300}}, \"data\": {\"url\": \"https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/mobility.csv\"}, \"mark\": {\"type\": \"point\"}, \"encoding\": {\"color\": {\"field\": \"Income\", \"scale\": {\"scheme\": \"viridis\"}, \"type\": \"quantitative\"}, \"x\": {\"field\": \"Mobility\", \"type\": \"quantitative\"}, \"y\": {\"field\": \"Population\", \"type\": \"quantitative\"}}, \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.20.1.json\"}, {\"mode\": \"vega-lite\"});\n",
"</script>"
],
"text/plain": [
"alt.Chart(...)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scatter1 = alt.Chart(mobility_url).mark_point().encode(\n",
" x = 'Mobility:Q', # Q = quantitative \n",
" y = 'Population:Q',\n",
" color = alt.Color('Income:Q', scale=alt.Scale(scheme='viridis'))\n",
")\n",
"scatter1"
]
},
{
"cell_type": "code",
Expand Down

0 comments on commit 747afc5

Please sign in to comment.