starcore-explorer-bad/content/pyodide/matplotlib.ipynb

114 lines
36 KiB
Plaintext
Raw Normal View History

2023-06-24 01:19:43 +08:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"## Matplotlib"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(0, 10, 1000)\n",
"plt.plot(x, np.sin(x));"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAA9hAAAPYQGoP6dpAABmgklEQVR4nO3deXxTZdo+8OskaZKuKd1baKGFQtkLRUrZkQoILoy4oDgogzg6OqPCjCPvb9R3RmcYfd3GZWQYZXDfxhVUFMsOZWspe0sXoPveJt2X5Pz+yAIVKKVNcpKc6/v55A/DSXqnwsl1zvM89yOIoiiCiIiIiGRDIXUBRERERORcDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMsMASERERCQzDIBEREREMqOSugB3ZjKZUFpaCn9/fwiCIHU5RERE1AOiKKKhoQFRUVFQKOR5L4wBsA9KS0sRHR0tdRlERETUC0VFRRgwYIDUZUiCAbAP/P39AZj/AgUEBEhcDREREfWEwWBAdHS07XtcjhgA+8A67BsQEMAASERE5GbkPH1LngPfRERERDLGAEhEREQkMwyARERERDLDAEhEREQkMwyARERERDLDAEhEREQkMwyARERERDLDAEhEREQkMwyARERERDLjFgFw586duPHGGxEVFQVBEPDVV19d8TXbt2/H+PHjodFoMGTIEGzYsOGiYz777DMkJCRAq9Vi9OjR+O677+xfPBEREZGLcYsA2NTUhLFjx+KNN97o0fFnzpzBggULMGvWLGRlZeHRRx/Ffffdhx9++MF2zN69e3HnnXdi+fLlOHz4MBYuXIiFCxfi+PHjjvoYRERERC5BEEVRlLqIqyEIAr788kssXLjwssf88Y9/xLffftslzC1evBj19fXYvHkzAOCOO+5AU1MTNm3aZDtm0qRJSExMxNq1a3tUi8FggE6ng16v517AREREboLf34BK6gIcIT09HampqV2emzt3Lh599NEux6xcufKiY7obXm5ra0NbW5vtvw0Gg13qpe7pWzqwv6AGOeUNKDO0oqPTBB+1EtFBPhgRFYCkgf2gUSmlLpOI3Fyn0YTDRfU4VqxHYW0zmto6oVIKiAjwxtBwP0yKC0Y/X7XUZRLZhUcGwPLycoSHh3d5Ljw8HAaDAS0tLfD29r7sMeXl5Zd93zVr1uDPf/6zQ2qmrkwmEWnZlfhg/znsPF0FUzf3qf01KswZGYHlU2MxIkqeV3JE1Hu5FQ3YsPcsNh4phaG187LHKQQgOTYYS1MGYs7ICCgVghOrJLIvjwyAjrJ69eoudw0NBgOio6MlrMgz7c2rxrPfnsLJsvN3WONCfDEuph/69/OG1kuBprZO5FU2IrOwHlUNbfg8sxifZxbjuhHheHLBCMQE+0j4CYjIHZTpW/D377PxdVap7blAHy8kxwZhUIgvArRe6DCaUFzXguMlemSXNyC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pbMPidfuQW9mI/oHeeHf5RAwO9bPb+7d3mvDHz4/iy8MlUCoEvHHXOMwbFWm39yf74/e3m+wEQp7naHE9fvN+JtqNJlw/KgKv3zXeruEPMM/X+eyByYgL8UWpvhV3v7UfNY1tV34hEXmMhtYO3P32AeRWNiIiQIuPVkyya/gDALVKgRdvG4tbkwbAaBLx248OY3dutV1/BpG9MQCS0xXXNeNXGw6hpcOIafEhePXOcfBSOuavYqi/Bu/fl4z+gd4oqG7Cg+9nor3T5JCfRUSuxWgS8cjHWThVZkCInwYfrEh2WIsohULAc4vGYMGYSHQYRfzmgwwUVDU65GcR2QMDIDlVc3snlm84hOrGNiRE+OOfS8Y7LPxZRQV6451fXQN/jQoHztbiL5tOOPTnEZFreP6HbGzNroRGpcDb90yw+52/n1MqBLx421iMjwmEobUT971zCPrmDof+TKLeYgAkp3ryqxPIqWhAqL8G6++9Bv5OatEyJMwfryxOhCAA7+8rxEcHCp3yc4lIGpuOluJfOwoAAM/fOgZjowOd8nO1Xkr865cTEKXToqC6CY99mgVOtSdXxABITvPpoSJ8nlkMhQC8duc4py/ImD08HL+fMwwA8L/fnEBuRYNTfz4ROUdRbTNWf3EMAPDAjMFOX5Ub6q/Bv++ZALVKga3ZlfjPnrNO/flEPcEASE6RV9mIp74+DgBYed1QTIrrXZ+/vnpwxmBMHxqKtk4TfvdxFto6jZLUQUSO0Wk04dFPstDQ2onxMYH4/ZyhktQxMkqHPy0YDgD4+/fZOFGql6QOosthACSHM5pE/OG/R9DaYcK0+BD8ZuYQyWpRKAS8cOsYBPmqcarMgP/bnCNZLURkf29sy0fGuTr4a1T4x+JxUDl4jnF3fjlpIFKHh6PdaMLvPjqM1g5ecJLrYAAkh3t7dwEOF9bDX6PCc4vG9Lrrvr2EBWjxf7eOMde25wwyC+skrYeI7ON0RQNe35YLAHj2F6MQHeSYFb89JQgC/u/WMQj11yC/qgmvb82TtB6iCzE
"text/plain": [
"<pyolite.display.Image object at 0x254e300>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"## Matplotlib: support for widgets backend"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install -q ipympl"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(0, 10, 1000)\n",
"plt.plot(x, np.sin(x))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (Pyodide)",
"language": "python",
"name": "python"
},
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8"
},
"orig_nbformat": 4,
"toc-showcode": false
},
"nbformat": 4,
"nbformat_minor": 4
}