Skip to content

Instantly share code, notes, and snippets.

@msund
Last active Jun 6, 2016
Embed
What would you like to do?
All of 'em
{
"metadata": {
"name": "Three new matplotlib plots"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": "21 Interactive Plots from matplotlib, ggplot for Python,<br>prettyplotlib, Stack Overflow, and seaborn"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Plotly is collaborative, makes beautiful interactive graphs with a URL for you, and stores your data and graphs together. This NB shows how to use Plotly to share plots from some awesome Python plotting libraries. The matplotlylib project is a collaboration with [mpld3](http://mpld3.github.io/index.html) and [Jake Vanderplas](https://github.com/jakevdp). We've put together a [User Guide](http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s00_homepage/s00_homepage.ipynb#Installation-guidelines) that outlines the full extent of Plotly's APIs.\n\nFor best results, you can copy and paste this Notebook and key. Run `$ pip install plotly` inside a terminal then start up a Notebook. We'll also be using ggplot, seaborn, and prettyplotlib, which you can also all install form pip. Let's get started."
},
{
"cell_type": "code",
"collapsed": false,
"input": "%matplotlib inline\nimport matplotlib.pyplot as plt # side-stepping mpl backend\nimport matplotlib.gridspec as gridspec # subplots\nimport numpy as np",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can use our public key and username or sign up for an account on [Plotly](plot.ly/ssi). Plotly is free for public use, you own your data, and you control the privacy. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "import plotly.plotly as py\nimport plotly.tools as tls\nfrom plotly.graph_objs import *\npy.sign_in(\"IPython.Demo\", \"1fw3zw2o13\")",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": "# tls.set_credentials_file(\"IPython.Demo\", \"1fw3zw2o13\")\n# tls.get_credentials_file()",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You'll want to have version 1.0.0. If not, run `$ pip install plotly --upgrade` in a terminal. Check out our User Guide for more details on [where to get your key](http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s00_homepage/s00_homepage.ipynb#Installation-guidelines). Problems or questions? Email feedback@plot.ly or find us on [Twitter](https://twitter.com/plotlygraphs)."
},
{
"cell_type": "code",
"collapsed": false,
"input": "import plotly\nplotly.__version__",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": "'1.0.0'"
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": "I. matplotlib Gallery graphs"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "For matplotlib experts, you'll recognize these graphs from the [matplotlib gallery](matplotlib.org/gallery.html). \n\nIn addition to matplotlib and Plotly's own [Python API](https://plot.ly/python), You can also use Plotly's other [APIs](https://plot.ly/api) for MATLAB, R, Perl, Julia, and REST to write to graphs. That means you and I could edit the same graph with any language. We can even edit the graph and data from the GUI, so technical and non-technical teams can work together. And all the graphs go to your profile, like this: https://plot.ly/~IPython.Demo.\n\nYou control [the privacy](http://plot.ly/python/privacy) by setting `world_readable` to False or True, and can control your [sharing](http://plot.ly/python/file-sharing)."
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Let's get started with this [damped oscillation](http://matplotlib.org/examples/pylab_examples/legend_demo2.html) graph."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig1 = plt.figure()\n# Make a legend for specific lines.\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\nt1 = np.arange(0.0, 2.0, 0.1)\nt2 = np.arange(0.0, 2.0, 0.01)\n\n# note that plot returns a list of lines. The \"l1, = plot\" usage\n# extracts the first element of the list into l1 using tuple\n# unpacking. So l1 is a Line2D instance, not a sequence of lines\nl1, = plt.plot(t2, np.exp(-t2))\nl2, l3 = plt.plot(t2, np.sin(2 * np.pi * t2), '--go', t1, np.log(1 + t1), '.')\nl4, = plt.plot(t2, np.exp(-t2) * np.sin(2 * np.pi * t2), 'rs-.')\n\nplt.xlabel('time')\nplt.ylabel('volts')\nplt.title('Damped oscillation')\n\nplt.show()",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAEZCAYAAABrUHmEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXt8FOW5+L+bANlEIOEe7ksiNcSASbiJIglaBE1Rq1LE\nqqDWUooEj1VPexQZrK0W6ymXWo6n8jO0iD2KhQJRJCIBAblIEhEIaoPL/RICCbckhmR+f8zuZvaW\n7CabveX55jOfndvOvjN5Zp55n9trUFVVRRAEQRA8ICLQDRAEQRBCB1EagiAIgseI0hAEQRA8RpSG\nIAiC4DGiNARBEASPEaUhCIIgeIwoDUFoImazmYiICOrq6vzye3feeSd///vfAcjJyeGWW26xbYuI\niODQoUNNOu4777zD+PHjfdJGIfwRpSEEFJPJRExMDB07dqR///7ceuutrFy5MtDNCko+/PBDHn74\n4WYdw5Wi++lPf8rHH3/c3OYJrQRRGkJAMRgMrFu3jgsXLvDBBx9w44038tRTT/HMM88EumlhjeT0\nCk1FlIYQNAwbNozf//73zJs3jwULFvDvf/8bgNzcXNLS0oiNjWXcuHH87W9/s33H+ua8cuVKkpKS\nGDBgAO+++y7FxcWMHj2aAQMGsHDhQtv+OTk5jB49mhdeeIFevXoxefJkiouLbdsrKytZunQpI0aM\nYPTo0bz//vu2B6yqqqxYsYLk5GRSU1PZsmVLg+dz/PhxXnjhBUwmE48++iiFhYW2bVu3buWOO+6g\nc+fO9OnTh9dff922bc+ePcyYMYPu3btz7bXXsmHDBgAyMzNZunRpo9exoes1ZswYAOLi4ujYsSM7\nduxwMnV98803ZGdn069fP2bPns23335r25aZmcmrr77K+PHj6dmzJ08//TTl5eWNtkkII1RBCCAm\nk0nduHGj3brS0lK1TZs26j/+8Q9VVVU1P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xC8QpSGIHjJH/7wBxITEyksLOS1116z27ZlyxaWL1/Opk2b\nmDFjBufOnWPv3r1ER0ezYcMGAF588UUeeOABPv/8cyZPnsz8+fMDcRqC0CRCpvaUIAQLeouuo3X3\nhz/8Id27dwegU6dOTJkyBYBRo0bx+eefc/fdd/Phhx9SUFDgvwYLgg8RpSEIPiQuLs42365dO9ty\nu3btqK6upq6ujoiICHbs2CGVWYWQRMxTguAlPXr04MKFC159x9ojadeuHXfeeSdLliyhtrYWVVXZ\nu3dvSzRTEFoEURqC4CXR0dFMnjyZ9PR0nnvuOdsoZwaDwW7EM8d56/K8efM4deoUw4YNIyUlhTVr\n1vj3BAShGUjIrSAIguAx0tMQBEEQPEaUhiAIguAxojQEQRAEjxGlIQiCIHiMKA1BEATBY0RpCIIg\nCB4jSkMQBEHwGFEagiAIgsf8f6/NeKkjAey4AAAAAElFTkSuQmCC\n",
"text": "<matplotlib.figure.Figure at 0x106091750>"
}
],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Now, to convert it to a Plotly figure, this is all it takes:"
},
{
"cell_type": "code",
"collapsed": false,
"input": "py.iplot_mpl(fig1)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3560\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x101ad27d0>"
}
],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can hover, zoom, and pan on the figure. You can also strip out the matplotlib styling, and use Plotly's default styling."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = tls.mpl_to_plotly(fig1)\nfig['layout'].update(showlegend=True)\nfig.strip_style()\npy.iplot(fig)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3561\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1060a17d0>"
}
],
"prompt_number": 7
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Next up, an example from [pylab](http://matplotlib.org/examples/pylab_examples/arctest.html)."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig2 = plt.figure()\n\nfrom pylab import *\n\ndef f(t):\n 'a damped exponential'\n s1 = cos(2*pi*t)\n e1 = exp(-t)\n return multiply(s1,e1)\n\nt1 = arange(0.0, 5.0, .2)\n\n\nl = plot(t1, f(t1), 'ro')\nsetp(l, 'markersize', 30)\nsetp(l, 'markerfacecolor', 'b')\n\npy.iplot_mpl(fig2)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3562\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10639a550>"
}
],
"prompt_number": 8
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Here's where this gets special. You can get the data from any Plotly graph. That means you can re-plot the graph or part of it, or use your favorite Python tools to wrangle and analyze your data. Check out our [getting started guide](http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s0_getting-started/s0_getting-started.ipynb) for a full background on these features."
},
{
"cell_type": "code",
"collapsed": false,
"input": "tls.mpl_to_plotly(fig2).get_data()",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": "[{'name': '_line0',\n 'x': [0.0,\n 0.20000000000000001,\n 0.40000000000000002,\n 0.60000000000000009,\n 0.80000000000000004,\n 1.0,\n 1.2000000000000002,\n 1.4000000000000001,\n 1.6000000000000001,\n 1.8,\n 2.0,\n 2.2000000000000002,\n 2.4000000000000004,\n 2.6000000000000001,\n 2.8000000000000003,\n 3.0,\n 3.2000000000000002,\n 3.4000000000000004,\n 3.6000000000000001,\n 3.8000000000000003,\n 4.0,\n 4.2000000000000002,\n 4.4000000000000004,\n 4.6000000000000005,\n 4.8000000000000007],\n 'y': [1.0,\n 0.25300171651849518,\n -0.54230030891302927,\n -0.44399794031078654,\n 0.13885028597711233,\n 0.36787944117144233,\n 0.09307413008823949,\n -0.19950113459002566,\n -0.16333771416280363,\n 0.051080165611754998,\n 0.1353352832366127,\n 0.034240058964379601,\n -0.073392365906047419,\n -0.060088587008433003,\n 0.018791342780197139,\n 0.049787068367863944,\n 0.012596213757493282,\n -0.026999542555766767,\n -0.022105355809443925,\n 0.0069129486808399343,\n 0.018315638888734179,\n 0.0046338880779826647,\n -0.0099325766273000524,\n -0.0081321059420741033,\n 0.0025431316975542792]}]"
}
],
"prompt_number": 9
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Or you can get the figure makeup. Here, we're using 'IPython.Demo', which is the username and '3357' which is the figure number. You can use this command on Plotly graphs to interact with them from the console. You can access graphs via a URL. For example, for this plot, it's:\n\nhttps://plot.ly/~IPython.Demo/3357/\n"
},
{
"cell_type": "code",
"collapsed": false,
"input": "pylab = py.get_figure('IPython.Demo', '3357')",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": "#print figure\nprint pylab.to_string()",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "Figure(\n data=Data([\n Scatter(\n x=[0.0, 0.2, 0.4, 0.6000000000000001, 0.8, 1.0, 1.2000000000000...],\n y=[1.0, 0.2530017165184952, -0.5423003089130293, -0.44399794031...],\n name='_line0',\n mode='markers',\n marker=Marker(\n symbol='dot',\n line=Line(\n color='#000000',\n width=0.5\n ),\n size=30,\n color='#0000FF',\n opacity=1\n )\n )\n ]),\n layout=Layout(\n xaxis=XAxis(\n domain=[0.0, 1.0],\n range=[0.0, 5.0],\n showline=True,\n ticks='inside',\n showgrid=False,\n zeroline=False,\n anchor='y',\n mirror=True\n ),\n yaxis=YAxis(\n domain=[0.0, 1.0],\n range=[-0.6000000000000001, 1.2],\n showline=True,\n ticks='inside',\n showgrid=False,\n zeroline=False,\n anchor='x',\n mirror=True\n ),\n hovermode='closest',\n showlegend=False\n )\n)\n"
}
],
"prompt_number": 11
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Now let's suppose we wanted to add a fit to the graph (see our [fits post](http://blog.plot.ly/post/84402951992/contour-plots-error-bars-chocolate-beer-meat) to learn more), and re-style it a bit. We can go into the web app, fork a copy, and edit the image in our GUI. No coding required."
},
{
"cell_type": "code",
"collapsed": false,
"input": "from IPython.display import Image\nImage(url='https://i.imgur.com/WG0gb9J.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"https://i.imgur.com/WG0gb9J.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 12,
"text": "<IPython.core.display.Image at 0x10043b910>"
}
],
"prompt_number": 12
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We also keep the data and graph together. You can analyze it, share it, or add to other plots. You can [append data](https://plot.ly/python/add-append-extend) to your plots, copy and paste, import, or upload data. Take-away: a Python user could make plots with an Excel user, [ggplot2 Ploty package](ropensci.org/blog/2014/04/17/plotly/), and [MATLAB](plot.ly/MATLAB) user. That's collaboration. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "Image(url='https://i.imgur.com/Mq490fb.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"https://i.imgur.com/Mq490fb.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 13,
"text": "<IPython.core.display.Image at 0x10639a650>"
}
],
"prompt_number": 13
},
{
"cell_type": "markdown",
"metadata": {},
"source": "I can now call that graph into the NB. I can keep the styling, re-use that styling on future graphs, and save styles from other graphs. And if I want to see the data for the fit or access the figure styling, I can run the same commands, but on the updated figure and data for this graph. I don't need to re-code it, and I can save and share this version. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "tls.embed('MattSundquist', '1307')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~MattSundquist/1307\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1060bff90>"
}
],
"prompt_number": 14
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Plotly graphs are always interactive, and you can even [stream data to the browser](http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s7_streaming/s7_streaming.ipynb). You can also embed them in the browser with an iframe snippet."
},
{
"cell_type": "code",
"collapsed": false,
"input": "from IPython.display import HTML",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 15
},
{
"cell_type": "code",
"collapsed": false,
"input": "s = \"\"\"<pre style=\"background:#f1f1f1;color:#000\">&lt;iframe src=<span style=\"color:#c03030\">\"https://plot.ly/~etpinard/176/650/550\"</span> width=<span style=\"color:#c03030\">\"650\"</span> height=550<span style=\"color:#c03030\">\" frameBorder=\"</span>0<span style=\"color:#c03030\">\" seamless=\"</span>seamless<span style=\"color:#c03030\">\" scrolling=\"</span>no<span style=\"color:#c03030\">\">&lt;/iframe></span></pre>\"\"\"",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 16
},
{
"cell_type": "code",
"collapsed": false,
"input": "h = HTML(s); h",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<pre style=\"background:#f1f1f1;color:#000\">&lt;iframe src=<span style=\"color:#c03030\">\"https://plot.ly/~etpinard/176/650/550\"</span> width=<span style=\"color:#c03030\">\"650\"</span> height=550<span style=\"color:#c03030\">\" frameBorder=\"</span>0<span style=\"color:#c03030\">\" seamless=\"</span>seamless<span style=\"color:#c03030\">\" scrolling=\"</span>no<span style=\"color:#c03030\">\">&lt;/iframe></span></pre>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 17,
"text": "<IPython.core.display.HTML at 0x1060bf350>"
}
],
"prompt_number": 17
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Where it remains interactive. That means your for-free defaults are: D3 graphs, drawn with JavaScript, and shared data. Here's how it looks in the Washington Post."
},
{
"cell_type": "code",
"collapsed": false,
"input": "Image(url='http://i.imgur.com/XjvtYMr.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"http://i.imgur.com/XjvtYMr.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 18,
"text": "<IPython.core.display.Image at 0x10639ad90>"
}
],
"prompt_number": 18
},
{
"cell_type": "markdown",
"metadata": {},
"source": "It's fun to zoom. Then double-click to re-size. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "HTML('<br><center><iframe class=\"vine-embed\" src=\"https://vine.co/v/Mvzin6HZzLB/embed/simple\" width=\"600\" height=\"600\" frameborder=\"0\"></iframe><script async src=\"//platform.vine.co/static/scripts/embed.js\" charset=\"utf-8\"></script></center><br>')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<br><center><iframe class=\"vine-embed\" src=\"https://vine.co/v/Mvzin6HZzLB/embed/simple\" width=\"600\" height=\"600\" frameborder=\"0\"></iframe><script async src=\"//platform.vine.co/static/scripts/embed.js\" charset=\"utf-8\"></script></center><br>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 19,
"text": "<IPython.core.display.HTML at 0x1060a3150>"
}
],
"prompt_number": 19
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Plots can be collaboratively edited and shared with others."
},
{
"cell_type": "code",
"collapsed": false,
"input": "Image(url='https://i.imgur.com/CxIYtzG.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"https://i.imgur.com/CxIYtzG.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 20,
"text": "<IPython.core.display.Image at 0x1060bff90>"
}
],
"prompt_number": 20
},
{
"cell_type": "markdown",
"metadata": {},
"source": "So you can keep all your plots for your project, team, or personal work in one plce, you get a profile, like this: https://plot.ly/~jackp/. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "Image(url='https://i.imgur.com/gUC4ajR.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"https://i.imgur.com/gUC4ajR.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 21,
"text": "<IPython.core.display.Image at 0x1060bfc90>"
}
],
"prompt_number": 21
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can also plot with Plotly with pandas, NumPy, datetime, and more of your favorite Python tools. We've already imported numpy and matplotlib; here we've kept them in so you can simply copy and paste these examples into your own NB. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig3 = plt.figure()\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# make a little extra space between the subplots\nplt.subplots_adjust(wspace=0.5)\n\ndt = 0.01\nt = np.arange(0, 30, dt)\nnse1 = np.random.randn(len(t)) # white noise 1\nnse2 = np.random.randn(len(t)) # white noise 2\nr = np.exp(-t/0.05)\n\ncnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1\ncnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2\n\n# two signals with a coherent part and a random part\ns1 = 0.01*np.sin(2*np.pi*10*t) + cnse1\ns2 = 0.01*np.sin(2*np.pi*10*t) + cnse2\n\nplt.subplot(211)\nplt.plot(t, s1, 'b-', t, s2, 'g-')\nplt.xlim(0,5)\nplt.xlabel('time')\nplt.ylabel('s1 and s2')\nplt.grid(True)\n\nplt.subplot(212)\ncxy, f = plt.csd(s1, s2, 256, 1./dt)\nplt.ylabel('CSD (db)')\n\npy.iplot_mpl(fig3)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3563\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x106435a90>"
}
],
"prompt_number": 22
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Another subplotting example using Plotly's defaults. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig4 = plt.figure()\n\nfrom pylab import figure, show\nfrom numpy import arange, sin, pi\n\nt = arange(0.0, 1.0, 0.01)\n\nfig = figure(1)\n\nax1 = fig.add_subplot(211)\nax1.plot(t, sin(2*pi*t))\nax1.grid(True)\nax1.set_ylim( (-2,2) )\nax1.set_ylabel('1 Hz')\nax1.set_title('A sine wave or two')\n\nfor label in ax1.get_xticklabels():\n label.set_color('r')\n\n\nax2 = fig.add_subplot(212)\nax2.plot(t, sin(2*2*pi*t))\nax2.grid(True)\nax2.set_ylim( (-2,2) )\nl = ax2.set_xlabel('Hi mom')\nl.set_color('g')\nl.set_fontsize('large')\n\npy.iplot_mpl(fig4, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3564\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x106488d50>"
}
],
"prompt_number": 23
},
{
"cell_type": "markdown",
"metadata": {},
"source": "From the gallery here we're shwoing [Anscombe's quartet](http://matplotlib.org/examples/pylab_examples/anscombe.html). You might also like Plotly's [blog post](blog.plot.ly/post/68951620673/why-graph-anscombes-quartet) on the subject."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig5 = plt.figure()\n\nfrom __future__ import print_function\n\"\"\"\nEdward Tufte uses this example from Anscombe to show 4 datasets of x\nand y that have the same mean, standard deviation, and regression\nline, but which are qualitatively different.\n\nmatplotlib fun for a rainy day\n\"\"\"\n\nfrom pylab import *\n\nx = array([10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5])\ny1 = array([8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68])\ny2 = array([9.14, 8.14, 8.74, 8.77, 9.26, 8.10, 6.13, 3.10, 9.13, 7.26, 4.74])\ny3 = array([7.46, 6.77, 12.74, 7.11, 7.81, 8.84, 6.08, 5.39, 8.15, 6.42, 5.73])\nx4 = array([8,8,8,8,8,8,8,19,8,8,8])\ny4 = array([6.58,5.76,7.71,8.84,8.47,7.04,5.25,12.50,5.56,7.91,6.89])\n\ndef fit(x):\n return 3+0.5*x\n\n\n\nxfit = array( [amin(x), amax(x) ] )\n\nsubplot(221)\nplot(x,y1,'ks', xfit, fit(xfit), 'r-', lw=2)\naxis([2,20,2,14])\nsetp(gca(), xticklabels=[], yticks=(4,8,12), xticks=(0,10,20))\ntext(3,12, 'I', fontsize=20)\n\nsubplot(222)\nplot(x,y2,'ks', xfit, fit(xfit), 'r-', lw=2)\naxis([2,20,2,14])\nsetp(gca(), xticklabels=[], yticks=(4,8,12), yticklabels=[], xticks=(0,10,20))\ntext(3,12, 'II', fontsize=20)\n\nsubplot(223)\nplot(x,y3,'ks', xfit, fit(xfit), 'r-', lw=2)\naxis([2,20,2,14])\ntext(3,12, 'III', fontsize=20)\nsetp(gca(), yticks=(4,8,12), xticks=(0,10,20))\n\nsubplot(224)\n\nxfit = array([amin(x4),amax(x4)])\nplot(x4,y4,'ks', xfit, fit(xfit), 'r-', lw=2)\naxis([2,20,2,14])\nsetp(gca(), yticklabels=[], yticks=(4,8,12), xticks=(0,10,20))\ntext(3,12, 'IV', fontsize=20)\n\n#verify the stats\npairs = (x,y1), (x,y2), (x,y3), (x4,y4)\nfor x,y in pairs:\n print ('mean=%1.2f, std=%1.2f, r=%1.2f'%(mean(y), std(y), corrcoef(x,y)[0][1]))\n\npy.iplot_mpl(fig5, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "mean=7.50, std=1.94, r=0.82\nmean=7.50, std=1.94, r=0.82\nmean=7.50, std=1.94, r=0.82\nmean=7.50, std=1.94, r=0.82\n"
},
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3565\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x106d446d0>"
}
],
"prompt_number": 24
},
{
"cell_type": "markdown",
"metadata": {},
"source": "And a final [histogram](http://matplotlib.org/examples/statistics/histogram_demo_features.html) from the matplotlib gallery. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig6 = plt.figure()\n\nimport numpy as np\nimport matplotlib.mlab as mlab\nimport matplotlib.pyplot as plt\n\n\n# example data\nmu = 100 # mean of distribution\nsigma = 15 # standard deviation of distribution\nx = mu + sigma * np.random.randn(10000)\n\nnum_bins = 50\n# the histogram of the data\nn, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5)\n# add a 'best fit' line\ny = mlab.normpdf(bins, mu, sigma)\nplt.plot(bins, y, 'r--')\nplt.xlabel('Smarts')\nplt.ylabel('Probability')\n\n# Tweak spacing to prevent clipping of ylabel\nplt.subplots_adjust(left=0.15)\n\npy.iplot_mpl(fig6, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3566\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x106cf8d10>"
}
],
"prompt_number": 25
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Want to see more matplotlylib graphs? Head over to our [API](https://plot.ly/python) and copy and paste away."
},
{
"cell_type": "code",
"collapsed": false,
"input": "Image(url='https://i.imgur.com/HEJEnjQ.png')",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<img src=\"https://i.imgur.com/HEJEnjQ.png\"/>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 26,
"text": "<IPython.core.display.Image at 0x106372890>"
}
],
"prompt_number": 26
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "II. ggplot for Python"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "An exciting package by [Greg Lamp](https://github.com/glamp) and the team at [\u0177hat](https://yhathq.com/) is [ggplot for Python](https://github.com/yhat/ggplot). You can draw figures with ggplot's wonderful syntax and share them with Plotly. You'll want to run `$ pip install ggplot` to get started."
},
{
"cell_type": "code",
"collapsed": false,
"input": "from ggplot import *",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 27
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We'll start out with a plot from the diamonds dataset. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "a = ggplot(aes(x='price'), data=diamonds) + geom_histogram() + facet_wrap(\"cut\") ",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 28
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Then share it to Plotly."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = a.draw() \npy.iplot_mpl(fig, strip_style=True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3582\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1126eb490>"
}
],
"prompt_number": 52
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Line charts can be interactive (drag your mouse along the line to see the data on the hover)."
},
{
"cell_type": "code",
"collapsed": false,
"input": "b = ggplot(aes(x='date', y='beef'), data=meat) + \\\n geom_line() ",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 30
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = b.draw() \npy.iplot_mpl(fig)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3568\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10645a490>"
}
],
"prompt_number": 31
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Histograms are also fun to hover over to get the exact data. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "c = ggplot(aes(x='price'), data=diamonds) + geom_histogram() + ggtitle('My Diamond Histogram')",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 32
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = c.draw() \npy.iplot_mpl(fig, strip_style=True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3569\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1115a4b50>"
}
],
"prompt_number": 33
},
{
"cell_type": "code",
"collapsed": false,
"input": "d = ggplot(aes(x='x', y='y', color='z'), data=diamonds.head(1000)) +\\\n geom_point() ",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 34
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = d.draw() \npy.iplot_mpl(fig, strip_style=True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3570\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110c96f90>"
}
],
"prompt_number": 35
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can also use more advanced plotting types in collaboration with pandas. You can add a geom."
},
{
"cell_type": "code",
"collapsed": false,
"input": "import pandas as pd",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 36
},
{
"cell_type": "code",
"collapsed": false,
"input": "random_walk1 = pd.DataFrame({\n \"x\": np.arange(100),\n \"y\": np.cumsum(np.random.choice([-1, 1], 100))\n})\nrandom_walk2 = pd.DataFrame({\n \"x\": np.arange(100),\n \"y\": np.cumsum(np.random.choice([-1, 1], 100))\n})\ne = ggplot(aes(x='x', y='y'), data=random_walk1) + \\\n geom_step() + \\\n geom_step(aes(x='x', y='y'), data=random_walk2)",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 37
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig = e.draw() \npy.iplot_mpl(fig, strip_style=True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3571\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110c1c210>"
}
],
"prompt_number": 38
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "III. Prettyplotlib graphs in Plotly"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "The lovely gallery of [examples](http://nbviewer.ipython.org/github/olgabot/prettyplotlib/blob/master/ipython_notebooks/Examples%20of%20everything%20pretty%20and%20plotted!.ipynb?create=1) from [prettyplotlib](https://github.com/olgabot/prettyplotlib), a matplotlib enhnacing library by [Olga Botvinnik](https://github.com/olgabot), is a fun one to make interactive. Here's a scatter; let us know if you make others. You'll note that not all elements of the styling come through. Head over to [the homepage](http://olgabot.github.io/prettyplotlib/) for documentation."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig12 = plt.figure()\n\nimport prettyplotlib as ppl\n\n# Set the random seed for consistency\nnp.random.seed(12)\n\n# Show the whole color range\nfor i in range(8):\n x = np.random.normal(loc=i, size=800)\n y = np.random.normal(loc=i, size=800)\n ax = ppl.scatter(x, y, label=str(i))\n \nppl.legend(ax)\nax.set_title('prettyplotlib `scatter`')\nax.legend().set_visible(False)\n\npy.iplot_mpl(fig12)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3572\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x111596390>"
}
],
"prompt_number": 39
},
{
"cell_type": "markdown",
"metadata": {},
"source": "And another prettyplotlib example."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig13 = plt.figure()\n\nimport prettyplotlib as ppl\n\n# Set the random seed for consistency\nnp.random.seed(12)\n\n# Show the whole color range\nfor i in range(8):\n y = np.random.normal(size=1000).cumsum()\n x = np.arange(1000)\n\n # Specify both x and y\n ppl.plot(x, y, label=str(i), linewidth=0.75)\n \npy.iplot_mpl(fig13)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3573\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110171b50>"
}
],
"prompt_number": 40
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "IV. Plotting with seaborn"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Another library we really dig is [seaborn](http://stanford.edu/~mwaskom/software/seaborn/index.html), a library to maximize aesthetics of matplotlib plots. It's by by [Michael Waskom](http://stanford.edu/~mwaskom/). You'll need to install it with ` $ pip install seaborn`, and may need to [import six](http://stackoverflow.com/questions/13967428/importerror-no-module-named-six), which you can do from pip. The styling isn't yet translated to Plotly, so we'll go to Plotly's default settings. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "import seaborn as sns\nfrom matplotlylib import fig_to_plotly",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 41
},
{
"cell_type": "code",
"collapsed": false,
"input": "def sinplot(flip=1):\n x = np.linspace(0, 14, 100)\n for i in range(1, 7):\n plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 42
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig14 = plt.figure()\n\nsns.set_style(\"dark\")\nsinplot()\n\npy.iplot_mpl(fig14, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3574\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110c84f50>"
}
],
"prompt_number": 43
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can also run subplots like this."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig15 = plt.figure()\n\nwith sns.axes_style(\"darkgrid\"):\n plt.subplot(211)\n sinplot()\nplt.subplot(212)\nsinplot(-1)\n\npy.iplot_mpl(fig15, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3575\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110ce3150>"
}
],
"prompt_number": 44
},
{
"cell_type": "markdown",
"metadata": {},
"source": "And a final example, [combining plot types](http://stanford.edu/~mwaskom/software/seaborn/tutorial/plotting_distributions.html#basic-visualization-with-histograms)."
},
{
"cell_type": "code",
"collapsed": false,
"input": "import numpy as np\nfrom numpy.random import randn\nimport pandas as pd\nfrom scipy import stats\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport seaborn as sns",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 45
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig16 = plt.figure()\n\nsns.set_palette(\"hls\")\nmpl.rc(\"figure\", figsize=(8, 4))\ndata = randn(200)\nsns.distplot(data);\n\npy.iplot_mpl(fig16, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3576\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110cf2550>"
}
],
"prompt_number": 46
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": "V. Stack Overflow Answers"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We love Stack Overflow, so wanted answer a few questions from there, in Plotly. If you want to plot data you already have as a [histogram](http://stackoverflow.com/questions/5328556/histogram-matplotlib) and make it interactive, try this one out."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig17 = plt.figure()\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nmu, sigma = 100, 15\nx = mu + sigma * np.random.randn(10000)\nhist, bins = np.histogram(x, bins=50)\nwidth = 0.7 * (bins[1] - bins[0])\ncenter = (bins[:-1] + bins[1:]) / 2\nplt.bar(center, hist, align='center', width=width)\n\npy.iplot_mpl(fig17, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3577\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x11157f510>"
}
],
"prompt_number": 47
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Here is how to create a [density plot](http://stackoverflow.com/questions/4150171/how-to-create-a-density-plot-in-matplotlib/4152016#4152016) like you might in R, but in matplotlib."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig18 = plt.figure()\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.stats import gaussian_kde\ndata = [1.5]*7 + [2.5]*2 + [3.5]*8 + [4.5]*3 + [5.5]*1 + [6.5]*8\ndensity = gaussian_kde(data)\nxs = np.linspace(0,8,200)\ndensity.covariance_factor = lambda : .25\ndensity._compute_covariance()\nplt.plot(xs,density(xs))\n\npy.iplot_mpl(fig18, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3578\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110cec910>"
}
],
"prompt_number": 48
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Drawing a simple example of [different lines for different plots](http://stackoverflow.com/questions/4805048/how-to-get-different-lines-for-different-plots-in-a-single-figure/4805456#4805456) looks like this..."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig19 = plt.figure()\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.arange(10)\n\nplt.plot(x, x)\nplt.plot(x, 2 * x)\nplt.plot(x, 3 * x)\nplt.plot(x, 4 * x)\n\npy.iplot_mpl(fig19, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3579\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10fade810>"
}
],
"prompt_number": 49
},
{
"cell_type": "markdown",
"metadata": {},
"source": "...and can get more exciting like this."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig20 = plt.figure()\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nnum_plots = 10\n\n# Have a look at the colormaps here and decide which one you'd like:\n# http://matplotlib.org/1.2.1/examples/pylab_examples/show_colormaps.html\ncolormap = plt.cm.gist_ncar\nplt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.9, num_plots)])\n\n# Plot several different functions...\nx = np.arange(10)\nlabels = []\nfor i in range(1, num_plots + 1):\n plt.plot(x, i * x + 5 * i)\n labels.append(r'$y = %ix + %i$' % (i, 5*i))\n\npy.iplot_mpl(fig20, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3580\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10f9f0110>"
}
],
"prompt_number": 50
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Plotly also lets you draw [variables as subscripts in math mode](http://stackoverflow.com/questions/23276918/writing-variables-as-subscripts-in-math-mode)."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig21 = plt.figure()\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport matplotlib.mlab as mlab\n\nmean = [10,12,16,22,25]\nvariance = [3,6,8,10,12]\n\nx = np.linspace(0,40,1000)\n\nfor i in range(4):\n sigma = np.sqrt(variance[i])\n y = mlab.normpdf(x,mean[i],sigma)\n plt.plot(x,y, label=r'$v_{}$'.format(i+1))\n\nplt.xlabel(\"X\")\nplt.ylabel(\"P(X)\") \n\npy.iplot_mpl(fig21, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3581\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10f9f9d10>"
}
],
"prompt_number": 51
},
{
"cell_type": "code",
"collapsed": false,
"input": "# CSS styling within IPython notebook\nfrom IPython.core.display import HTML\nimport urllib2\ndef css_styling():\n url = 'https://raw.githubusercontent.com/plotly/python-user-guide/master/custom.css'\n styles = urllib2.urlopen(url).read()\n return HTML(styles)\n\ncss_styling()",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<style>\n /*body {\n background-color: #F5F5F5;\n }*/\n div.cell{\n width: 850px;\n margin-left: 10% !important;\n margin-right: auto;\n }\n h1 {\n font-family: 'Open sans',verdana,arial,sans-serif;\n }\n .text_cell_render h1 {\n font-weight: 200;\n font-size: 40pt;\n line-height: 100%;\n color:#447adb;\n margin-bottom: 0em;\n margin-top: 0em;\n display: block;\n white-space: nowrap;\n } \n h2 {\n font-family: 'Open sans',verdana,arial,sans-serif;\n text-indent:1em;\n }\n .text_cell_render h2 {\n font-weight: 200;\n font-size: 20pt;\n font-style: italic;\n line-height: 100%;\n color:#447adb;\n margin-bottom: 1.5em;\n margin-top: 0.5em;\n display: block;\n white-space: nowrap;\n } \n h3 {\n font-family: 'Open sans',verdana,arial,sans-serif;\n }\n .text_cell_render h3 {\n font-weight: 300;\n font-size: 18pt;\n line-height: 100%;\n color:#447adb;\n margin-bottom: 0.5em;\n margin-top: 2em;\n display: block;\n white-space: nowrap;\n }\n h4 {\n font-family: 'Open sans',verdana,arial,sans-serif;\n }\n .text_cell_render h4 {\n font-weight: 300;\n font-size: 16pt;\n color:#447adb;\n margin-bottom: 0.5em;\n margin-top: 0.5em;\n display: block;\n white-space: nowrap;\n }\n h5 {\n font-family: 'Open sans',verdana,arial,sans-serif;\n }\n .text_cell_render h5 {\n font-weight: 300;\n font-style: normal;\n color: #1d3b84;\n font-size: 16pt;\n margin-bottom: 0em;\n margin-top: 1.5em;\n display: block;\n white-space: nowrap;\n }\n div.text_cell_render{\n font-family: 'Open sans',verdana,arial,sans-serif;\n line-height: 135%;\n font-size: 125%;\n width:750px;\n margin-left:auto;\n margin-right:auto;\n text-align:justify;\n text-justify:inter-word;\n }\n div.output_subarea.output_text.output_pyout {\n overflow-x: auto;\n overflow-y: scroll;\n max-height: 300px;\n }\n div.output_subarea.output_stream.output_stdout.output_text {\n overflow-x: auto;\n overflow-y: scroll;\n max-height: 300px;\n }\n code{\n font-size: 78%;\n }\n .rendered_html code{\n background-color: transparent;\n }\n ul{\n /* color:#447adb; */ // colors text too\n margin: 2em;\n }\n ul li{\n padding-left: 0.5em; \n margin-bottom: 0.5em; \n margin-top: 0.5em; \n }\n ul li li{\n padding-left: 0.2em; \n margin-bottom: 0.2em; \n margin-top: 0.2em; \n }\n ol{\n /* color:#447adb; */ // colors text too\n margin: 2em;\n }\n ol li{\n padding-left: 0.5em; \n margin-bottom: 0.5em; \n margin-top: 0.5em; \n }\n /*.prompt{\n display: None;\n } */\n ul li{\n padding-left: 0.5em; \n margin-bottom: 0.5em; \n margin-top: 0.2em; \n }\n a:link{\n font-weight: bold;\n color:#447adb;\n }\n a:visited{\n font-weight: bold;\n color: #1d3b84;\n }\n a:hover{\n font-weight: bold;\n color: #1d3b84;\n }\n a:focus{\n font-weight: bold;\n color:#447adb;\n }\n a:active{\n font-weight: bold;\n color:#447adb;\n }\n .rendered_html :link {\n text-decoration: none; \n }\n .rendered_html :hover {\n text-decoration: none; \n }\n .rendered_html :visited {\n text-decoration: none;\n }\n .rendered_html :focus {\n text-decoration: none;\n }\n .rendered_html :active {\n text-decoration: none;\n }\n .warning{\n color: rgb( 240, 20, 20 )\n } \n hr {\n color: #f3f3f3;\n background-color: #f3f3f3;\n height: 1px;\n }\n blockquote{\n display:block;\n background: #f3f3f3;\n font-family: 'Open sans',verdana,arial,sans-serif;\n width:610px;\n padding: 15px 15px 15px 15px;\n text-align:justify;\n text-justify:inter-word;\n }\n blockquote p {\n margin-bottom: 0;\n line-height: 125%;\n font-size: 100%;\n }\n /* element.style {\n } */ \n</style>\n<script>\n MathJax.Hub.Config({\n TeX: {\n extensions: [\"AMSmath.js\"]\n },\n tex2jax: {\n inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n },\n displayAlign: 'center', // Change this to 'center' to center equations.\n \"HTML-CSS\": {\n styles: {'.MathJax_Display': {\"margin\": 4}}\n }\n });\n</script>\n",
"metadata": {},
"output_type": "pyout",
"prompt_number": 1,
"text": "<IPython.core.display.HTML at 0x102c04110>"
}
],
"prompt_number": 1
}
],
"metadata": {}
}
]
}
@cqcn1991

This comment has been minimized.

Copy link

@cqcn1991 cqcn1991 commented Jun 6, 2016

What about adding a sidebar it? So it would be easier to navigate through the notebook.
Mine is like this:
https://nbviewer.jupyter.org/github/cqcn1991/Wind-Speed-Analysis/blob/master/GMM.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment