Created
May 3, 2015 15:19
-
-
Save dpsanders/bbca4a5f2737319163bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "# First install `mpld3` using\n", | |
| "# pip install mpld3" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "using PyCall" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "@pyimport matplotlib.pyplot as plt\n", | |
| "@pyimport mpld3 as mpld3" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": { | |
| "collapsed": false, | |
| "scrolled": true | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "\n", | |
| "\n", | |
| "<style>\n", | |
| "\n", | |
| "</style>\n", | |
| "\n", | |
| "<div id=\"fig_el715547208233129355118050\"></div>\n", | |
| "<script>\n", | |
| "function mpld3_load_lib(url, callback){\n", | |
| " var s = document.createElement('script');\n", | |
| " s.src = url;\n", | |
| " s.async = true;\n", | |
| " s.onreadystatechange = s.onload = callback;\n", | |
| " s.onerror = function(){console.warn(\"failed to load library \" + url);};\n", | |
| " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", | |
| "}\n", | |
| "\n", | |
| "if(typeof(mpld3) !== \"undefined\" && mpld3._mpld3IsLoaded){\n", | |
| " // already loaded: just create the figure\n", | |
| " !function(mpld3){\n", | |
| " \n", | |
| " mpld3.draw_figure(\"fig_el715547208233129355118050\", {\"axes\": [{\"xlim\": [0.0, 4.0], \"yscale\": \"linear\", \"axesbg\": \"#FFFFFF\", \"texts\": [], \"zoomable\": true, \"images\": [], \"xdomain\": [0.0, 4.0], \"ylim\": [1.0, 5.0], \"paths\": [], \"sharey\": [], \"sharex\": [], \"axesbgalpha\": null, \"axes\": [{\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"bottom\", \"nticks\": 9, \"tickvalues\": null}, {\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"left\", \"nticks\": 9, \"tickvalues\": null}], \"lines\": [{\"color\": \"#000000\", \"yindex\": 1, \"coordinates\": \"data\", \"dasharray\": \"10,0\", \"zorder\": 2, \"alpha\": 1, \"xindex\": 0, \"linewidth\": 1.0, \"data\": \"data01\", \"id\": \"el71554721582352\"}], \"markers\": [{\"edgecolor\": \"#FFFFFF\", \"facecolor\": \"#000000\", \"edgewidth\": 5, \"yindex\": 1, \"coordinates\": \"data\", \"zorder\": 2, \"markerpath\": [[[-10.0, 10.0], [10.0, 10.0], [10.0, -10.0], [-10.0, -10.0]], [\"M\", \"L\", \"L\", \"L\", \"Z\"]], \"alpha\": 1, \"xindex\": 0, \"data\": \"data01\", \"id\": \"el71554721582352pts\"}], \"id\": \"el71554720449232\", \"ydomain\": [1.0, 5.0], \"collections\": [], \"xscale\": \"linear\", \"bbox\": [0.125, 0.099999999999999978, 0.77500000000000002, 0.80000000000000004]}], \"height\": 480.0, \"width\": 640.0, \"plugins\": [{\"type\": \"reset\"}, {\"enabled\": false, \"button\": true, \"type\": \"zoom\"}, {\"enabled\": false, \"button\": true, \"type\": \"boxzoom\"}], \"data\": {\"data01\": [[0.0, 3.0], [1.0, 1.0], [2.0, 4.0], [3.0, 1.0], [4.0, 5.0]]}, \"id\": \"el71554720823312\"});\n", | |
| " }(mpld3);\n", | |
| "}else if(typeof define === \"function\" && define.amd){\n", | |
| " // require.js is available: use it to load d3/mpld3\n", | |
| " require.config({paths: {d3: \"https://mpld3.github.io/js/d3.v3.min\"}});\n", | |
| " require([\"d3\"], function(d3){\n", | |
| " window.d3 = d3;\n", | |
| " mpld3_load_lib(\"https://mpld3.github.io/js/mpld3.v0.2.js\", function(){\n", | |
| " \n", | |
| " mpld3.draw_figure(\"fig_el715547208233129355118050\", {\"axes\": [{\"xlim\": [0.0, 4.0], \"yscale\": \"linear\", \"axesbg\": \"#FFFFFF\", \"texts\": [], \"zoomable\": true, \"images\": [], \"xdomain\": [0.0, 4.0], \"ylim\": [1.0, 5.0], \"paths\": [], \"sharey\": [], \"sharex\": [], \"axesbgalpha\": null, \"axes\": [{\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"bottom\", \"nticks\": 9, \"tickvalues\": null}, {\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"left\", \"nticks\": 9, \"tickvalues\": null}], \"lines\": [{\"color\": \"#000000\", \"yindex\": 1, \"coordinates\": \"data\", \"dasharray\": \"10,0\", \"zorder\": 2, \"alpha\": 1, \"xindex\": 0, \"linewidth\": 1.0, \"data\": \"data01\", \"id\": \"el71554721582352\"}], \"markers\": [{\"edgecolor\": \"#FFFFFF\", \"facecolor\": \"#000000\", \"edgewidth\": 5, \"yindex\": 1, \"coordinates\": \"data\", \"zorder\": 2, \"markerpath\": [[[-10.0, 10.0], [10.0, 10.0], [10.0, -10.0], [-10.0, -10.0]], [\"M\", \"L\", \"L\", \"L\", \"Z\"]], \"alpha\": 1, \"xindex\": 0, \"data\": \"data01\", \"id\": \"el71554721582352pts\"}], \"id\": \"el71554720449232\", \"ydomain\": [1.0, 5.0], \"collections\": [], \"xscale\": \"linear\", \"bbox\": [0.125, 0.099999999999999978, 0.77500000000000002, 0.80000000000000004]}], \"height\": 480.0, \"width\": 640.0, \"plugins\": [{\"type\": \"reset\"}, {\"enabled\": false, \"button\": true, \"type\": \"zoom\"}, {\"enabled\": false, \"button\": true, \"type\": \"boxzoom\"}], \"data\": {\"data01\": [[0.0, 3.0], [1.0, 1.0], [2.0, 4.0], [3.0, 1.0], [4.0, 5.0]]}, \"id\": \"el71554720823312\"});\n", | |
| " });\n", | |
| " });\n", | |
| "}else{\n", | |
| " // require.js not available: dynamically load d3 & mpld3\n", | |
| " mpld3_load_lib(\"https://mpld3.github.io/js/d3.v3.min.js\", function(){\n", | |
| " mpld3_load_lib(\"https://mpld3.github.io/js/mpld3.v0.2.js\", function(){\n", | |
| " \n", | |
| " mpld3.draw_figure(\"fig_el715547208233129355118050\", {\"axes\": [{\"xlim\": [0.0, 4.0], \"yscale\": \"linear\", \"axesbg\": \"#FFFFFF\", \"texts\": [], \"zoomable\": true, \"images\": [], \"xdomain\": [0.0, 4.0], \"ylim\": [1.0, 5.0], \"paths\": [], \"sharey\": [], \"sharex\": [], \"axesbgalpha\": null, \"axes\": [{\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"bottom\", \"nticks\": 9, \"tickvalues\": null}, {\"scale\": \"linear\", \"tickformat\": null, \"grid\": {\"gridOn\": false}, \"fontsize\": 12.0, \"position\": \"left\", \"nticks\": 9, \"tickvalues\": null}], \"lines\": [{\"color\": \"#000000\", \"yindex\": 1, \"coordinates\": \"data\", \"dasharray\": \"10,0\", \"zorder\": 2, \"alpha\": 1, \"xindex\": 0, \"linewidth\": 1.0, \"data\": \"data01\", \"id\": \"el71554721582352\"}], \"markers\": [{\"edgecolor\": \"#FFFFFF\", \"facecolor\": \"#000000\", \"edgewidth\": 5, \"yindex\": 1, \"coordinates\": \"data\", \"zorder\": 2, \"markerpath\": [[[-10.0, 10.0], [10.0, 10.0], [10.0, -10.0], [-10.0, -10.0]], [\"M\", \"L\", \"L\", \"L\", \"Z\"]], \"alpha\": 1, \"xindex\": 0, \"data\": \"data01\", \"id\": \"el71554721582352pts\"}], \"id\": \"el71554720449232\", \"ydomain\": [1.0, 5.0], \"collections\": [], \"xscale\": \"linear\", \"bbox\": [0.125, 0.099999999999999978, 0.77500000000000002, 0.80000000000000004]}], \"height\": 480.0, \"width\": 640.0, \"plugins\": [{\"type\": \"reset\"}, {\"enabled\": false, \"button\": true, \"type\": \"zoom\"}, {\"enabled\": false, \"button\": true, \"type\": \"boxzoom\"}], \"data\": {\"data01\": [[0.0, 3.0], [1.0, 1.0], [2.0, 4.0], [3.0, 1.0], [4.0, 5.0]]}, \"id\": \"el71554720823312\"});\n", | |
| " })\n", | |
| " });\n", | |
| "}\n", | |
| "</script>" | |
| ], | |
| "text/plain": [ | |
| "PyObject <IPython.core.display.HTML object>" | |
| ] | |
| }, | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "plt.ioff()\n", | |
| "plt.plot([3,1,4,1,5], \"ks-\", mec=\"w\", mew=5, ms=20)\n", | |
| "mpld3.display()" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Julia 0.3.8-pre", | |
| "language": "julia", | |
| "name": "julia 0.3" | |
| }, | |
| "language_info": { | |
| "name": "julia", | |
| "version": "0.3.9" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment