{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# PyData Library Styles\n", "\n", "This theme has built-in support and special styling for several major visualization libraries in the PyData ecosystem.\n", "This ensures that the images and output generated by these libraries looks good for both light and dark modes.\n", "Below are examples of each that we use as a benchmark for reference." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pandas" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import string\n", "\n", "import numpy as np\n", "import pandas as pd\n", "\n", "\n", "rng = np.random.default_rng(seed=15485863)\n", "data = rng.standard_normal((100, 26))\n", "df = pd.DataFrame(data, columns=list(string.ascii_lowercase))\n", "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPyWidget" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipywidgets as widgets\n", "import numpy as np\n", "import pandas as pd\n", "\n", "from IPython.display import display\n", "\n", "\n", "tab = widgets.Tab()\n", "\n", "descr_str = \"Hello\"\n", "\n", "title = widgets.HTML(descr_str)\n", "\n", "# create output widgets\n", "widget_images = widgets.Output()\n", "widget_annotations = widgets.Output()\n", "\n", "# render in output widgets\n", "with widget_images:\n", " display(pd.DataFrame(np.random.randn(10, 10)))\n", "with widget_annotations:\n", " display(pd.DataFrame(np.random.randn(10, 10)))\n", "\n", "tab.children = [widget_images, widget_annotations]\n", "tab.titles = [\"Images\", \"Annotations\"]\n", "\n", "display(widgets.VBox([title, tab]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Matplotlib" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "\n", "fig, ax = plt.subplots()\n", "ax.scatter(df[\"a\"], df[\"b\"], c=df[\"b\"], s=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rng = np.random.default_rng()\n", "data = rng.standard_normal((3, 100))\n", "fig, ax = plt.subplots()\n", "ax.scatter(data[0], data[1], c=data[2], s=3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Xarray\n", "\n", "Here we demonstrate `xarray` to ensure that it shows up properly." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "\n", "\n", "data = xr.DataArray(\n", " np.random.randn(2, 3), dims=(\"x\", \"y\"), coords={\"x\": [10, 20]}, attrs={\"foo\": \"bar\"}\n", ")\n", "data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ipyleaflet\n", "\n", "`ipyleaflet` is a **Jupyter**/**Leaflet** bridge enabling interactive maps in the Jupyter notebook environment. this demonstrate how you can integrate maps in your documentation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import Map, basemaps\n", "\n", "\n", "# display a map centered on France\n", "m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.6" } }, "nbformat": 4, "nbformat_minor": 2 }