{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Nbsphinx example\n", "This example renders a Jupyter notebook using the ``nbsphinx`` extension." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot a simple sphere using PyVista.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pyvista as pv\n", "\n", "pv.set_jupyter_backend(\"html\")\n", "\n", "sphere = pv.Sphere()\n", "sphere.plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plotter = pv.Plotter(notebook=True)\n", "plotter.add_mesh(sphere, color=\"white\", show_edges=True)\n", "plotter.title = \"3D Sphere Visualization\"\n", "plotter.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Render equations using the IPython ``math`` module." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import Math\n", "\n", "eq = Math(r\"\\int\\limits_{-\\infty}^\\infty f(x) \\delta(x - x_0) dx = f(x_0)\")\n", "eq" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import Latex\n", "\n", "Latex(r\"This is a \\LaTeX{} equation: $a^2 + b^2 = c^2$\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Render a table in markdown." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is an example to render the table inside the notebook\n", "\n", "A | B | A and B\n", "------|-------|--------\n", "False | False | False\n", "True | False | False\n", "False | True | False\n", "True | True | True\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Render a data frame" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "# Create a dictionary of data\n", "data = {\n", " \"A\": [True, False, True, False],\n", " \"B\": [False, True, False, True],\n", " \"C\": [True, True, False, False],\n", "}\n", "\n", "# Create DataFrame from the dictionary\n", "df = pd.DataFrame(data)\n", "\n", "# Display the DataFrame\n", "df.head()" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }