{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# This is an H1\n", "## This is an H2\n", "### This is an H3\n", "#### This is an H4\n", "##### This is an H5\n", "###### This is an H6\n", "\n", "This is a block of text. \n", "\n", "- Here is a list\n", "- of items\n", "\n", "\n", "1. and\n", "2. a few \n", "3. numbers\n", "\n", "> this is a quote\n", "\n", "All you need to do is `pip install plotly` and then `import plotly.plotly as py`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Emailing Plotly Graphs\n", "\n", "In the [Plotly Webapp](https://plotly.com/plot) you can share your graphs over email to your colleagues who are also Plotly members. If your making graphs periodically or automatically, e.g. [in Python with a cron job](http://moderndata.plot.ly/update-plotly-charts-with-cron-jobs-and-python/), it can be helpful to also share the graphs that you're creating in an email to your team.\n", "\n", "This notebook is a primer on sending nice HTML emails with *Plotly* **graphs** in Python. We use:\n", "- [Plotly](https://plotly.com/python/) for interactive, web native graphs\n", "- [IPython Notebook](https://plotly.com/ipython-notebooks) to create this notebook, combining text, HTML, and Python code\n", "- [`smtplib` and `email`](https://docs.python.org/2/library/email-examples.html) libraries included in the Python standard library" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# This is a comment\n", "from plotly.offline import iplot, init_notebook_mode" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "init_notebook_mode()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Drawing...
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot([{'x': [1, 2, 3], 'y': [3, 1, 5]}])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Updating graphs\n", "\n", "If we use the same `filename`, the graph will save to the same URL. So, if we include a graph in an email by it's URL, we can update that graph by calling `py.plot` with the same filename." ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "11\n", "12\n", "13\n", "14\n", "15\n", "16\n", "17\n", "18\n", "19\n", "20\n", "21\n", "22\n", "23\n", "24\n", "25\n", "26\n", "27\n", "28\n", "29\n", "30\n", "31\n", "32\n", "33\n", "34\n", "35\n", "36\n", "37\n", "38\n", "39\n", "40\n", "41\n", "42\n", "43\n", "44\n", "45\n", "46\n", "47\n", "48\n", "49\n", "50\n", "51\n", "52\n", "53\n", "54\n", "55\n", "56\n", "57\n", "58\n", "59\n", "60\n", "61\n", "62\n", "63\n", "64\n", "65\n", "66\n", "67\n", "68\n", "69\n", "70\n", "71\n", "72\n", "73\n", "74\n", "75\n", "76\n", "77\n", "78\n", "79\n", "80\n", "81\n", "82\n", "83\n", "84\n", "85\n", "86\n", "87\n", "88\n", "89\n", "90\n", "91\n", "92\n", "93\n", "94\n", "95\n", "96\n", "97\n", "98\n", "99\n" ] } ], "source": [ "for i in range(100):\n", " print i" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already up-to-date: publisher in /Users/chriddyp/Repos/venvpy27/lib/python2.7/site-packages\r\n" ] }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "! pip install publisher --upgrade\n", "\n", "from IPython.display import HTML, display\n", "\n", "display(HTML(''))\n", "display(HTML(''))\n", "\n", "import publisher\n", "publisher.publish('style-template', '/python/style-template', \n", " 'Markdown CSS Style Template', \n", " 'Markdown CSS Style Template',\n", " uses_plotly_offline=True, sitemap='false')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 0 }