{ "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": {}, "source": [ "## facebook\n", "\n", "\n", "| asfasdfasdfasdf \t| asdfasdf \t| asdfasdf \t| asdfasdfasdf \t| asdfasdfasdfasdf \t|\n", "|-----------------\t|----------\t|----------\t|--------------\t|------------------\t|\n", "| 1324 \t| 2 \t| 2 \t| 1 \t| 1 \t|\n", "| 1234 \t| 2 \t| 2 \t| 1 \t| 1 \t|\n", "| 1234 \t| 2 \t| 2 \t| 2 \t| 1 \t|\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Stretch/Untouched | ProbDistribution | Accuracy |\n", "| :- | -: | :-: |\n", "| Stretched | Gaussian | .843" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
Sun 696000 1.9891e+09
Earth 63715973.6
Moon 1737 73.5
Mars 3390 641.85
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.display import HTML, display\n", "import tabulate\n", "table = [[\"Sun\",696000,1989100000],\n", " [\"Earth\",6371,5973.6],\n", " [\"Moon\",1737,73.5],\n", " [\"Mars\",3390,641.85]]\n", "display(HTML(tabulate.tabulate(table, tablefmt='html')))" ] }, { "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({'ints': [1, 2, 3], \n", " 'floats': [np.pi, np.exp(1), (1+np.sqrt(5))/2],\n", " 'strings': ['aardvark', 'bananarama', 'charcuterie' ]})\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.1" }, "pycharm": { "stem_cell": { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [] } } }, "nbformat": 4, "nbformat_minor": 1 }