{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true, "pycharm": { "name": "#%% md\n" } }, "source": [ "# Jupyter Notebooks\n", "\n", "The [nbsphinx extension](https://github.com/spatialaudio/nbsphinx) allow notebooks to be seemlessly integrated into a Sphinx website. This page demonstrates how notebooks are rendered. " ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Mathematics\n", "\n", "[MathJax](https://www.mathjax.org) can use used to render mathematical equations. Equations can\n", "be rendered either in their own line using double dollar signs \n", "\n", "$$ y_{it} = \\alpha_i + \\gamma_t + \\beta x_{it} + \\epsilon_{it} $$\n", "\n", "or inline using single dollar signs ($\\LaTeX$).\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## DataFrames\n", "\n", "pandas DataFrames are rendered with useful markup." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "is_executing": false, "name": "#%%\n" } }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "df = pd.DataFrame(\n", " {\n", " \"ints\": [1, 2, 3],\n", " \"floats\": [np.pi, np.exp(1), (1 + np.sqrt(5)) / 2],\n", " \"strings\": [\"aardvark\", \"bananarama\", \"charcuterie\"],\n", " }\n", ")\n", "\n", "df" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Plots and Figures\n", "\n", "matplotlib can be used to produce plots in notebooks\n", "\n", "This example comes from the [matplotlib gallery](https://matplotlib.org/3.1.1/gallery/ticks_and_spines/colorbar_tick_labelling_demo.html#sphx-glr-gallery-ticks-and-spines-colorbar-tick-labelling-demo-py)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "is_executing": false, "name": "#%%\n" } }, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "\n", "fig, ax = plt.subplots(figsize=(12, 8))\n", "\n", "data = np.clip(np.random.randn(250, 250), -1, 1)\n", "\n", "cax = ax.imshow(data, interpolation=\"nearest\", cmap=cm.coolwarm)\n", "ax.set_title(\"Gaussian noise with vertical colorbar\", fontsize=16)\n", "plt.tick_params(labelsize=16)\n", "\n", "# Add colorbar, make sure to specify tick locations to match desired ticklabels\n", "cbar = fig.colorbar(cax, ticks=[-1, 0, 1])\n", "cbar.ax.set_yticklabels([\"< -1\", \"0\", \"> 1\"]) # vertically oriented colorbar\n", "cbar.ax.tick_params(labelsize=16)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.4" }, "pycharm": { "stem_cell": { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [] } } }, "nbformat": 4, "nbformat_minor": 1 }