diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5d75eae8b..ccb9a74df 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -126,8 +126,12 @@ jobs: # version-pinning section for the full story before bumping this. # Once Safari (and Firefox out-of-flag) ship JSPI, revisit this pin # across RTB/MVTB/bdsim together. + # ipympl is installed here, in the build environment, so that the + # jupyter-matplotlib extension is bundled into the site: the notebooks + # use %matplotlib ipympl, and without the extension a figure is blank. + # (The notebooks install ipympl itself into the in-browser kernel.) run: | - pip install jupyterlite-core "jupyterlite-pyodide-kernel==0.6.1" jupyter-server + pip install jupyterlite-core "jupyterlite-pyodide-kernel==0.6.1" jupyter-server ipympl cd docs/lite && jupyter lite build --output-dir ../build/html/lite - name: Upload Pages artifact diff --git a/docs/notebooks/dynamics.ipynb b/docs/notebooks/dynamics.ipynb index 1a3ebf5f5..a1390850b 100644 --- a/docs/notebooks/dynamics.ipynb +++ b/docs/notebooks/dynamics.ipynb @@ -10,7 +10,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -29,7 +29,8 @@ " formatter={\"float\": lambda x: f\"{x:8.4g}\" if abs(x) > 1e-10 else f\"{0:8.4g}\"},\n", ")\n", "\n", - "%matplotlib notebook\n", + "%matplotlib ipympl\n", + "plt.close(\"all\")\n", "%config NotebookBackend.figure_format = 'retina'" ] }, @@ -1037,7 +1038,7 @@ } ], "source": [ - "p560.plot(p560.qn, block=False);" + "p560.plot(p560.qn);" ] }, { @@ -2139,8 +2140,7 @@ "fig.colorbar(surf, shrink=0.9, aspect=10, pad=0.12)\n", "ax.set_xlabel(\"$q_2$ (rad)\")\n", "ax.set_ylabel(\"$q_3$ (rad)\")\n", - "ax.set_zlabel(\"$M_{11}$ ($kg.m^2$)\")\n", - "plt.show()" + "ax.set_zlabel(\"$M_{11}$ ($kg.m^2$)\")" ] }, { @@ -3163,8 +3163,7 @@ "fig.colorbar(surf, shrink=0.9, aspect=10, pad=0.12)\n", "ax.set_xlabel(\"$q_2$ (rad)\")\n", "ax.set_ylabel(\"$q_3$ (rad)\")\n", - "ax.set_zlabel(\"$M_{12}$ ($kg.m^2$)\")\n", - "plt.show()" + "ax.set_zlabel(\"$M_{12}$ ($kg.m^2$)\")" ] }, { @@ -4382,7 +4381,7 @@ } ], "source": [ - "rtb.tools.trajectory.qplot(tg.t, tg.q)" + "rtb.tools.plot.xplot(tg.t, tg.q)" ] }, { diff --git a/docs/notebooks/ets.ipynb b/docs/notebooks/ets.ipynb index 4b8113733..5213678f3 100644 --- a/docs/notebooks/ets.ipynb +++ b/docs/notebooks/ets.ipynb @@ -48,7 +48,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -60,7 +60,7 @@ "from spatialmath import SE3\n", "from spatialmath.base import sym\n", "\n", - "%matplotlib notebook" + "%matplotlib ipympl" ] }, { diff --git a/docs/notebooks/icra2021.ipynb b/docs/notebooks/icra2021.ipynb index 54c67a116..34704b64e 100644 --- a/docs/notebooks/icra2021.ipynb +++ b/docs/notebooks/icra2021.ipynb @@ -36,7 +36,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -67,7 +67,7 @@ "\"\"\"\n", " )\n", ")\n", - "%matplotlib notebook" + "%matplotlib ipympl" ] }, { @@ -3458,7 +3458,7 @@ ], "source": [ "traj = jtraj(puma.qz, puma.qr, 100)\n", - "qplot(traj.q)" + "traj.qplot()" ] }, { @@ -4047,7 +4047,7 @@ } ], "source": [ - "panda.plot(panda.qr, block=False);" + "panda.plot(panda.qr);" ] }, { diff --git a/docs/notebooks/iros2020-workshop.ipynb b/docs/notebooks/iros2020-workshop.ipynb index 99629d52b..5861574b3 100644 --- a/docs/notebooks/iros2020-workshop.ipynb +++ b/docs/notebooks/iros2020-workshop.ipynb @@ -24,7 +24,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -43,7 +43,8 @@ " formatter={\"float\": lambda x: f\"{x:8.4g}\" if abs(x) > 1e-10 else f\"{0:8.4g}\"},\n", ")\n", "\n", - "%matplotlib notebook" + "%matplotlib ipympl\n", + "plt.close(\"all\")" ] }, { @@ -1465,7 +1466,7 @@ "outputs": [], "source": [ "tg = puma.nofriction().fdyn(5, puma.qn, dt=0.05)\n", - "rtb.tools.trajectory.qplot(tg.q, tg.t, block=True)" + "rtb.tools.plot.xplot(tg.t, tg.q)" ] }, { @@ -1672,9 +1673,7 @@ "ax.set_ylim3d(-10, 10)\n", "ax.set_zlim3d(-10, 10)\n", "\n", - "tw.line().plot(color=\"red\", linewidth=2)\n", - "\n", - "plt.show()" + "tw.line().plot(color=\"red\", linewidth=2)" ] }, { @@ -1914,9 +1913,8 @@ "metadata": {}, "outputs": [], "source": [ - "fig = puma.plot(puma.qz, block=False)\n", - "lines.plot(\"k--\", linewidth=1.5, bounds=np.r_[-1, 1, -1, 1, -1, 1.5])\n", - "plt.show()" + "fig = puma.plot(puma.qz)\n", + "lines.plot(\"k--\", linewidth=1.5, bounds=np.r_[-1, 1, -1, 1, -1, 1.5])" ] }, { diff --git a/docs/notebooks/kinematics.ipynb b/docs/notebooks/kinematics.ipynb index b37706d13..62609b59b 100644 --- a/docs/notebooks/kinematics.ipynb +++ b/docs/notebooks/kinematics.ipynb @@ -8,7 +8,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -27,7 +27,8 @@ " formatter={\"float\": lambda x: f\"{x:8.4g}\" if abs(x) > 1e-10 else f\"{0:8.4g}\"},\n", ")\n", "\n", - "%matplotlib notebook" + "%matplotlib ipympl\n", + "plt.close(\"all\")" ] }, { @@ -1417,7 +1418,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can plot this trajectory as a function of time using the convenience function `qplot`" + "We can plot this trajectory as a function of time using the convenience method `qplot`" ] }, { @@ -2370,7 +2371,7 @@ } ], "source": [ - "rtb.tools.trajectory.qplot(qt.q, block=False)" + "qt.qplot()" ] }, { diff --git a/docs/notebooks/robotics.ipynb b/docs/notebooks/robotics.ipynb index a7e99deb5..b24b8e3d4 100644 --- a/docs/notebooks/robotics.ipynb +++ b/docs/notebooks/robotics.ipynb @@ -500,7 +500,7 @@ "from roboticstoolbox import VehiclePolygon\n", "\n", "va = VehiclePolygon(piano)\n", - "map.plot(block=None)\n", + "map.plot()\n", "for i in np.unique(np.rint(np.linspace(0, len(path) - 1, 20)).astype(int)):\n", " va.plot(path[i, :], alpha=0.2)\n" ] diff --git a/docs/notebooks/symbolic.ipynb b/docs/notebooks/symbolic.ipynb index 17ceddffd..e9aee3424 100644 --- a/docs/notebooks/symbolic.ipynb +++ b/docs/notebooks/symbolic.ipynb @@ -8,7 +8,7 @@ "source": [ "try:\n", " import piplite\n", - " await piplite.install([\"roboticstoolbox-python\"])\n", + " await piplite.install([\"ipympl\", \"roboticstoolbox-python\"])\n", "except ImportError:\n", " pass # not running in Pyodide (e.g. local Jupyter) -- assume it's already pip-installed\n", "\n", @@ -22,7 +22,7 @@ "from spatialmath import SE3\n", "import spatialmath.base.symbolic as sym\n", "\n", - "%matplotlib notebook" + "%matplotlib ipympl" ] }, {