Skip to content

Instantly share code, notes, and snippets.

@msund
Last active June 6, 2016 12:08
Show Gist options
  • Save msund/11349097 to your computer and use it in GitHub Desktop.
Save msund/11349097 to your computer and use it in GitHub Desktop.
All of 'em
{
"metadata": {
"name": "Three new matplotlib plots"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "18 Interactive Plots from matplotlib, prettyplotlib, Stack Overflow, and seaborn"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "In this Notebook, we'll create interactive Plotly graphs from different Python libraries. It's easy, lets you collaborate, makes a D3 graph with a URL for you, and stores your data and graphs together. You can also always access the data from your graphs or any public Plotly graph. For a full walk-through and documentation, check out our [getting started Notebook](http://nbviewer.ipython.org/github/etpinard/plotly-python-doc/blob/1.0/s0_getting-started/s0_getting-started.ipynb). Let's set up our environment and packages."
},
{
"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": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": "import plotly.plotly as py\nimport plotly.tools as tls\nfrom plotly.graph_objs import *\n# py.sign_in(\"IPython.Demo\", \"1fw3zw2o13\")",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": "# tls.set_credentials_file(\"IPython.Demo\", \"1fw3zw2o13\")\n# tls.get_credentials_file()",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 14
},
{
"cell_type": "code",
"collapsed": false,
"input": "import plotly\nplotly.__version__",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 15,
"text": "'1.0.0'"
}
],
"prompt_number": 15
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": "I. Plotly for Teaching: Software Carpentry Notebook"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "These first two are drawn from the [Software Carpentry repo](http://nbviewer.ipython.org/github/swcarpentry/notebooks/blob/master/matplotlib.ipynb). First, we'll draw a matplotlib figure and show both the matplotlib figure and the Plotly graph."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig1 = plt.figure()\n\n#generate some data\nx = np.array(range(20))\ny = 3 + 0.5 * x + np.random.randn(20)\n\n#plot the data\nplt.plot(x, y, 'bo')\n\n#generate a mpl figure and Plotly figure\nplt.show()\npy.iplot_mpl(fig1)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAECCAYAAAAMxDf2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAETZJREFUeJzt3X9sU+Uex/FPt6HpfhAUyjIQNhJN1AjT/YExuAxz5/5A\nQmJsiKjFARHBgCTAkvFDIUJE/EWiE9ARzbWEGB1gQIPx3kGcgMkMf9yBsBiDaEYIdsjMvCwy6Ll/\n7Hbyc+tpz9npefp+/UXLSr95aD99dvo8zzdgWZYlAICv5XhdAAAgfYQ5ABiAMAcAAxDmAGAAwhwA\nDECYA4ABBg3z1tZWRSKRq+7bu3evnnzySdeKAgDYkzfQXzY2NmrPnj0qKCjov+/48ePauXOn64UB\nAJI34My8tLRUDQ0NSuwrOn/+vDZt2qSVK1eKvUYAkDkGDPOamhrl5uZKkuLxuFatWqX6+nrl5+cP\nSXEAgOQk/QXosWPH9Ouvv2rt2rVatmyZfvrpJ23YsMHN2gAASRrwmvmVJk2apC+++EKSdPr0aS1d\nulQrVqwY9HGWZSkQCKReIQBgUEmF+bVhbCegA4GAYrFu+5XhhkKhIsbTIYylsxhPZ4VCRbZ+PjAU\npybyH+wc3jDOYSydxXg6y26Ys2kIAAxAmAOAAQhzADAAYQ4ABiDMAcAAhDkAGIAwBwADEOYAYADC\nHAAMQJgDgAEIcwAwAGEOAAYgzAHAAIQ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HAAP8D8s6msCB5sF+AAAAAElFTkSuQmCC\n",
"text": "<matplotlib.figure.Figure at 0x10e073fd0>"
},
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3312\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e088410>"
}
],
"prompt_number": 16
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Now let's draw another figure. This time, we'll only print the converted Plotly version of the figure. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "x = np.array(range(20))\ny = 3 + 0.5 * x + np.random.randn(20)\nz = 2 + 0.9 * x + np.random.randn(20)",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 17
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig2 = plt.figure()\n\n#plot the data\nplt.plot(x, y, 'bo')\nplt.hold(True)\nplt.plot(x, z, 'r^')\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/3313\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e09c4d0>"
}
],
"prompt_number": 18
},
{
"cell_type": "markdown",
"metadata": {},
"source": "One special Plotly feature is that you'll get a URL with your data and graph. You can then go to Plotly's GUI and edit, tweak, and share your graph. Here's the URL:\n\nhttps://plot.ly/~IPython.Demo/3080\n\nAnd I've gone in to make a copy of the graph, and shared the data here:\n\nhttps://plot.ly/~MattSundquist/1190."
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "II. 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, 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": "Plotly also reads the label types in this [damped oscillation](http://matplotlib.org/examples/pylab_examples/legend_demo2.html) graph."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig3 = 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\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/3347\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110f2f710>"
}
],
"prompt_number": 59
},
{
"cell_type": "markdown",
"metadata": {},
"source": "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(fig3)\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/3315\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e5f1210>"
}
],
"prompt_number": 22
},
{
"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": "fig4 = 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(fig4)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3316\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e6ba410>"
}
],
"prompt_number": 23
},
{
"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. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "tls.mpl_to_plotly(fig4).get_data()",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 61,
"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": 61
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Or you can get the string to produce the graph using Plotly."
},
{
"cell_type": "code",
"collapsed": false,
"input": "tls.mpl_to_plotly(fig4).to_string(pretty = False)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 62,
"text": "\"Figure(\\n data=Data([\\n Scatter(\\n x=[0.0, 0.20000000000000001, 0.40000000000000002, 0.60000000000000009, 0.80000000000000004, 1.0, 1.2000000000000002, 1.4000000000000001, 1.6000000000000001, 1.8, 2.0, 2.2000000000000002, 2.4000000000000004, 2.6000000000000001, 2.8000000000000003, 3.0, 3.2000000000000002, 3.4000000000000004, 3.6000000000000001, 3.8000000000000003, 4.0, 4.2000000000000002, 4.4000000000000004, 4.6000000000000005, 4.8000000000000007],\\n y=[1.0, 0.25300171651849518, -0.54230030891302927, -0.44399794031078654, 0.13885028597711233, 0.36787944117144233, 0.09307413008823949, -0.19950113459002566, -0.16333771416280363, 0.051080165611754998, 0.1353352832366127, 0.034240058964379601, -0.073392365906047419, -0.060088587008433003, 0.018791342780197139, 0.049787068367863944, 0.012596213757493282, -0.026999542555766767, -0.022105355809443925, 0.0069129486808399343, 0.018315638888734179, 0.0046338880779826647, -0.0099325766273000524, -0.0081321059420741033, 0.0025431316975542792],\\n name='_line0',\\n mode='markers',\\n marker=Marker(\\n symbol='dot',\\n line=Line(\\n color='#000000',\\n width=0\\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=True,\\n zeroline=False,\\n anchor='y',\\n mirror=True\\n ),\\n yaxis=YAxis(\\n domain=[0.0, 1.0],\\n range=(-0.60000000000000009, 1.2),\\n showline=True,\\n ticks='inside',\\n showgrid=True,\\n zeroline=False,\\n anchor='x',\\n mirror=True\\n ),\\n width=480,\\n height=320,\\n autosize=False,\\n margin=Margin(\\n l=60,\\n r=47,\\n b=40,\\n t=31,\\n pad=0\\n ),\\n hovermode='closest',\\n showlegend=False\\n )\\n)\""
}
],
"prompt_number": 62
},
{
"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": "fig5 = 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(fig5)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3317\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e5ef510>"
}
],
"prompt_number": 24
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Another subplotting example, in this case we're using Plotly's defaults. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig6 = 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(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/3318\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e5f1550>"
}
],
"prompt_number": 25
},
{
"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": "fig7 = 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(fig7, 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/3319\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10f7301d0>"
}
],
"prompt_number": 26
},
{
"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": "fig8 = 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(fig8, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3349\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110f93b90>"
}
],
"prompt_number": 63
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "III. Stack Overflow Answers"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We love Stack Overflow, so wanted to show answers to 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": "fig9 = 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(fig9, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3321\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1100d3a10>"
}
],
"prompt_number": 28
},
{
"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": "fig10 = 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(fig10, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3322\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10fe131d0>"
}
],
"prompt_number": 29
},
{
"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": "fig11 = 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(fig11, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3323\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110297550>"
}
],
"prompt_number": 30
},
{
"cell_type": "markdown",
"metadata": {},
"source": "...and can get more exciting like this."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig12 = 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(fig12, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3324\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1102d43d0>"
}
],
"prompt_number": 31
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Plotly also shows LaTeX if you want to 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": "fig13 = 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(fig13, strip_style = True)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3325\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x1107c0810>"
}
],
"prompt_number": 32
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "IV. Prettyplotlib graphs in Plotly"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "The gallery of [examples](http://nbviewer.ipython.org/github/olgabot/prettyplotlib/blob/master/ipython_notebooks/Examples%20of%20everything%20pretty%20and%20plotted!.ipynb?create=1) we really like from [prettyplotlib](https://github.com/olgabot/prettyplotlib) can be 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. "
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig14 = 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(fig14)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3348\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x10e9d6050>"
}
],
"prompt_number": 60
},
{
"cell_type": "markdown",
"metadata": {},
"source": "And another prettyplotlib example."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig15 = 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 # For now, you need to specify both x and y :(\n # Still figuring out how to specify just one\n ppl.plot(x, y, label=str(i), linewidth=0.75)\n \npy.iplot_mpl(fig15)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~IPython.Demo/3346\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110fc72d0>"
}
],
"prompt_number": 56
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "V. Plotting with seaborn"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Another library we really dig is [seaborn](http://stanford.edu/~mwaskom/software/seaborn/index.html), by Michael Waskom. You 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": 44
},
{
"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": 45
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig16 = plt.figure()\n\nsns.set_style(\"dark\")\nsinplot()\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/3339\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110fab290>"
}
],
"prompt_number": 46
},
{
"cell_type": "markdown",
"metadata": {},
"source": "You can also run subplots like this."
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig17 = plt.figure()\n\nwith sns.axes_style(\"darkgrid\"):\n plt.subplot(211)\n sinplot()\nplt.subplot(212)\nsinplot(-1)\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/3340\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x111ab4150>"
}
],
"prompt_number": 47
},
{
"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": 42
},
{
"cell_type": "code",
"collapsed": false,
"input": "fig18 = plt.figure()\n\nsns.set_palette(\"hls\")\nmpl.rc(\"figure\", figsize=(8, 4))\ndata = randn(200)\nsns.distplot(data);\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/3341\" height=\"525\" width=\"100%\"></iframe>",
"metadata": {},
"output_type": "display_data",
"text": "<IPython.core.display.HTML at 0x110d1f550>"
}
],
"prompt_number": 48
},
{
"cell_type": "code",
"collapsed": false,
"input": "",
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
@cqcn1991
Copy link

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