{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "2021-06-15-analysis.ipynb", "provenance": [], "authorship_tag": "ABX9TyMP9lOoiRb14EQUoZiHc1hp", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "<a href=\"https://colab.research.google.com/github/arinbasu/2021-06-15-stencila/blob/main/main.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" ] }, { "cell_type": "code", "metadata": { "id": "VKRVxVsddx4x" }, "source": [ "import pandas as pd\n", "import numpy as np\n", "import altair as alt\n" ], "execution_count": 2, "outputs": [] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 368 }, "id": "KN868YB0d52D", "outputId": "9575ca02-53ff-4802-d987-6f739860d8ad" }, "source": [ "df = pd.DataFrame({\"x\" : [1,2,3,4],\n", " \"y\" : [4,5,6,7] })\n", "df\n", "\n", "chart = alt.Chart(df)\n", "chart.mark_point().encode(\n", " alt.X('x:Q'),\n", " alt.Y('y:Q')\n", ")" ], "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "alt.Chart(...)" ], "text/html": [ "\n", "<div id=\"altair-viz-8adc53c117d949689ee190311d61f621\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", " let outputDiv = document.currentScript.previousElementSibling;\n", " if (outputDiv.id !== \"altair-viz-8adc53c117d949689ee190311d61f621\") {\n", " outputDiv = document.getElementById(\"altair-viz-8adc53c117d949689ee190311d61f621\");\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@4.8.1?noext\",\n", " \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n", " };\n", "\n", " function loadScript(lib) {\n", " return new Promise(function(resolve, reject) {\n", " var s = document.createElement('script');\n", " s.src = paths[lib];\n", " s.async = true;\n", " s.onload = () => resolve(paths[lib]);\n", " s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\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 if (typeof vegaEmbed === \"function\") {\n", " displayChart(vegaEmbed);\n", " } else {\n", " loadScript(\"vega\")\n", " .then(() => loadScript(\"vega-lite\"))\n", " .then(() => loadScript(\"vega-embed\"))\n", " .catch(showError)\n", " .then(() => displayChart(vegaEmbed));\n", " }\n", " })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}}, \"data\": {\"name\": \"data-de055fd39ff076e4558953d2358ed82a\"}, \"mark\": \"point\", \"encoding\": {\"x\": {\"type\": \"quantitative\", \"field\": \"x\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"y\"}}, \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.8.1.json\", \"datasets\": {\"data-de055fd39ff076e4558953d2358ed82a\": [{\"x\": 1, \"y\": 4}, {\"x\": 2, \"y\": 5}, {\"x\": 3, \"y\": 6}, {\"x\": 4, \"y\": 7}]}}, {\"mode\": \"vega-lite\"});\n", "</script>" ] }, "metadata": { "tags": [] }, "execution_count": 3 } ] }, { "cell_type": "code", "metadata": { "id": "7EMq919cfUjQ" }, "source": [ "" ], "execution_count": null, "outputs": [] } ] }