78 lines
3.0 KiB
Plaintext
78 lines
3.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "52cc5dd5-93ce-4370-adc0-8842764a359e",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "ModuleNotFoundError",
|
|
"evalue": "No module named 'vega_datasets'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[1], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01maltair\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01malt\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mvega_datasets\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m data\n\u001b[1;32m 4\u001b[0m source \u001b[38;5;241m=\u001b[39m data\u001b[38;5;241m.\u001b[39mstocks()\n\u001b[1;32m 6\u001b[0m lines \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 7\u001b[0m alt\u001b[38;5;241m.\u001b[39mChart(source)\n\u001b[1;32m 8\u001b[0m \u001b[38;5;241m.\u001b[39mmark_line()\n\u001b[1;32m 9\u001b[0m \u001b[38;5;241m.\u001b[39mencode(x\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m\"\u001b[39m, y\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprice\u001b[39m\u001b[38;5;124m\"\u001b[39m, color\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymbol\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 10\u001b[0m )\n",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'vega_datasets'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import altair as alt\n",
|
|
"from vega_datasets import data\n",
|
|
"\n",
|
|
"source = data.stocks()\n",
|
|
"\n",
|
|
"lines = (\n",
|
|
" alt.Chart(source)\n",
|
|
" .mark_line()\n",
|
|
" .encode(x=\"date\", y=\"price\", color=\"symbol\")\n",
|
|
")\n",
|
|
"\n",
|
|
"xrule = (\n",
|
|
" alt.Chart()\n",
|
|
" .mark_rule(color=\"cyan\", strokeWidth=2)\n",
|
|
" .encode(x=alt.datum(alt.DateTime(year=2006, month=\"November\")))\n",
|
|
")\n",
|
|
"\n",
|
|
"yrule = (\n",
|
|
" alt.Chart().mark_rule(strokeDash=[12, 6], size=2).encode(y=alt.datum(350))\n",
|
|
")\n",
|
|
"\n",
|
|
"\n",
|
|
"lines + yrule + xrule"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1a208413-acd4-4ec5-a4ac-3e77558ec9bb",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.15"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|