Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

450 lines (450 sloc) 42.005 kb
{
"metadata": {
"name": "flotplot"
},
"nbformat": 3,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"source": [
"#Interactive inline plotting using flot",
"",
"This notebook demonstrates the use of the ipython notebook bindings to the javascript plotting libaray [flot](http://code.google.com/p/flot/). It allows for inline plotting along with basic interactivity (zooming). Since the plots are constructed at runtime in javascript the plots cannot be saved from session to session."
]
},
{
"cell_type": "code",
"input": [
"import flotplot"
],
"language": "python",
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"source": [
"In order to use the flot bindings it is necessary to create an instance of flot.Plot()"
]
},
{
"cell_type": "code",
"input": [
"plt = flotplot.Plot()"
],
"language": "python",
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "markdown",
"source": [
"In order to plot data use the plot_figure method. The plot_figure command can accept a single list, two lists, or two lists of lists. it also has a optional label keyword to label the dataset(s). An example of each of these plot is shown below. "
]
},
{
"cell_type": "code",
"input": [
"import numpy as np",
"x = np.linspace(0,10,100)",
"y = np.sin(x)",
"plt.plot_figure(y)"
],
"language": "python",
"outputs": [
{
"html": [
"",
" <div id=\"placeholder0\"\" style=\"width:",
" 600px;height:300px;\"></div>",
" <input id=\"home0\" type=\"button\" value=\"home\"> <input id=\"zoom0\" type=\"button\" value=\"zoom to selection\">",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x109c91910>"
]
},
{
"javascript": [
"$.getScript(\"http://crbates.github.com/flot/jquery.flot.min.js\", function () {",
"$.getScript(\"http://crbates.github.com/flot/jquery.flot.navigate.min.js\", function () {",
"$.getScript(\"http://crbates.github.com/flot/jquery.flot.selection.min.js\", function () {",
"var d1 = [[0.0, 0], [0.10083842025810461, 1], [0.20064885652268541, 2], [0.2984138044476411, 3], [0.39313661214832979, 4], [0.48385164043793466, 5], [0.56963410690896565, 6], [0.6496095135057065, 7], [0.72296256147946036, 8], [0.78894546284425737, 9], [0.84688556360298339, 10], [0.89619220102995634, 11], [0.93636272510428475, 12], [0.96698762270929961, 13], [0.98775469236008384, 14], [0.99845222690038948, 15], [0.99897117172335681, 16], [0.98930623651434013, 17], [0.96955594918232368, 18], [0.93992165143013118, 19], [0.90070544620295545, 20], [0.85230711793967529, 21], [0.7952200570230491, 22], [0.73002622997644639, 23], [0.65739024668277546, 24], [0.5780525851065732, 25], [0.49282204258892348, 26], [0.40256749066949654, 27], [0.30820901749007684, 28], [0.21070854807719289, 29], [0.11106003812412972, 30], [0.010279341240534697, 31], [-0.090606147033407733, 32], [-0.19056796287548539, 33], [-0.28858705872043244, 34], [-0.38366419180611233, 35], [-0.47483011082223953, 36], [-0.56115543681520175, 37], [-0.64176013761938777, 38], [-0.71582249922919017, 39], [-0.78258750265420218, 40], [-0.84137452086087006, 41], [-0.89158425733514024, 42], [-0.93270485553183358, 43], [-0.96431711692877831, 44], [-0.98609877449092964, 45], [-0.99782777797921263, 46], [-0.99938455761243572, 47], [-0.99075324300567713, 48], [-0.97202182495883338, 49], [-0.94338125844599963, 50], [-0.90512351595013674, 51], [-0.85763861098805172, 52], [-0.80141062216896974, 53], [-0.73701275831891344, 54], [-0.66510151497882242, 55], [-0.58640998184723503, 56], [-0.50174036939391131, 57], [-0.41195583083086279, 58], [-0.31797166281061867, 59], [-0.22074597455506337, 60], [-0.12126992053716677, 61], [-0.020557596287260064, 62], [0.080364299670281733, 63], [0.18046693235991093, 64], [0.27872981867755731, 65], [0.37415123057121996, 66], [0.46575840702565169, 67], [0.55261747074640588, 68], [0.63384294844890576, 69], [0.70860679769921819, 70], [0.77614684828358049, 71], [0.83577457205225891, 72], [0.8868821020290788, 73], [0.92894842923125132, 74], [0.96154471402682351, 75], [0.98433865788382358, 76], [0.9970978909438748, 77], [0.9996923408861117, 78], [0.99209555893232282, 79], [0.97438498947553576, 80], [0.94674118058335432, 81], [0.90944594342446261, 82], [0.86287947938178355, 83], [0.80751650413956255, 84], [0.74392140825684439, 85], [0.67274250356226473, 86], [0.59470541402449739, 87], [0.51060567847428295, 88], [0.42130064058860689, 89], [0.32770070881349983, 90], [0.23076007532505177, 91], [0.13146698864295842, 92], [0.03083367906114098, 93], [-0.070113960400646769, 94], [-0.1703468323280965, 95], [-0.26884312591038401, 96], [-0.36459873365588863, 97], [-0.45663748763377376, 98], [-0.54402111088936989, 99]];",
" var options = {",
" selection: { mode: \"xy\" },",
" legend: { position:\"ne\"},",
" };",
" ",
" var plot0 = $.plot($(\"#placeholder0\"), [ {data:d1}],options);",
" var minx0 = plot0.getAxes().xaxis.min;",
" var maxx0 = plot0.getAxes().xaxis.max;",
" var miny0 = plot0.getAxes().yaxis.min;",
" var maxy0 = plot0.getAxes().yaxis.max;",
" ",
" var iminx0 = plot0.getAxes().xaxis.min;",
" var imaxx0 = plot0.getAxes().xaxis.max;",
" var iminy0 = plot0.getAxes().yaxis.min;",
" var imaxy0 = plot0.getAxes().yaxis.max; ",
" ",
" $(\"#placeholder0\").bind(\"plotselected\", function (event, ranges) {",
" minx0 = ranges.xaxis.from;",
" maxx0 = ranges.xaxis.to;",
" miny0 = ranges.yaxis.from;",
" maxy0 = ranges.yaxis.to;",
" });",
" ",
"",
" $(\"#zoom0\").click(function() {",
" $.plot($(\"#placeholder0\"), plot0.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: minx0 , max: maxx0 },",
" yaxis: { min: miny0 , max: maxy0 }",
" }));",
"",
" });",
" ",
" $(\"#home0\").click(function() {",
" $.plot($(\"#placeholder0\"), plot0.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: iminx0 , max: imaxx0 },",
" yaxis: { min: iminy0 , max: imaxy0 }",
" }));",
"",
" });",
" });",
"});",
"});",
""
],
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x109c91910>"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"input": [
"plt.plot_figure(x,y)"
],
"language": "python",
"outputs": [
{
"html": [
"",
" <div id=\"placeholder1\"\" style=\"width:",
" 600px;height:300px;\"></div>",
" <input id=\"home1\" type=\"button\" value=\"home\"> <input id=\"zoom1\" type=\"button\" value=\"zoom to selection\">",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1cbb750>"
]
},
{
"javascript": [
"var d1 = [[0.0, 0.0], [0.10101010101010101, 0.10083842025810461], [0.20202020202020202, 0.20064885652268541], [0.30303030303030304, 0.2984138044476411], [0.40404040404040403, 0.39313661214832979], [0.50505050505050508, 0.48385164043793466], [0.60606060606060608, 0.56963410690896565], [0.70707070707070707, 0.6496095135057065], [0.80808080808080807, 0.72296256147946047], [0.90909090909090906, 0.78894546284425737], [1.0101010101010102, 0.84688556360298339], [1.1111111111111112, 0.89619220102995634], [1.2121212121212122, 0.93636272510428475], [1.3131313131313131, 0.96698762270929961], [1.4141414141414141, 0.98775469236008384], [1.5151515151515151, 0.99845222690038948], [1.6161616161616161, 0.99897117172335681], [1.7171717171717171, 0.98930623651434013], [1.8181818181818181, 0.96955594918232368], [1.9191919191919191, 0.93992165143013118], [2.0202020202020203, 0.90070544620295545], [2.1212121212121211, 0.85230711793967517], [2.2222222222222223, 0.7952200570230491], [2.3232323232323231, 0.73002622997644639], [2.4242424242424243, 0.65739024668277546], [2.5252525252525251, 0.5780525851065732], [2.6262626262626263, 0.49282204258892348], [2.7272727272727271, 0.40256749066949654], [2.8282828282828283, 0.30820901749007684], [2.9292929292929291, 0.21070854807719289], [3.0303030303030303, 0.11106003812412972], [3.131313131313131, 0.010279341240534697], [3.2323232323232323, -0.090606147033407733], [3.3333333333333335, -0.19056796287548539], [3.4343434343434343, -0.28858705872043244], [3.5353535353535355, -0.38366419180611233], [3.6363636363636362, -0.47483011082223947], [3.7373737373737375, -0.56115543681520175], [3.8383838383838382, -0.64176013761938777], [3.9393939393939394, -0.71582249922919017], [4.0404040404040407, -0.78258750265420218], [4.141414141414141, -0.84137452086087006], [4.2424242424242422, -0.89158425733514024], [4.3434343434343434, -0.93270485553183358], [4.4444444444444446, -0.9643171169287782], [4.545454545454545, -0.98609877449092964], [4.6464646464646462, -0.99782777797921263], [4.7474747474747474, -0.99938455761243572], [4.8484848484848486, -0.99075324300567713], [4.9494949494949498, -0.97202182495883338], [5.0505050505050502, -0.94338125844599963], [5.1515151515151514, -0.90512351595013674], [5.2525252525252526, -0.85763861098805172], [5.3535353535353538, -0.80141062216896974], [5.4545454545454541, -0.73701275831891333], [5.5555555555555554, -0.66510151497882242], [5.6565656565656566, -0.58640998184723514], [5.7575757575757578, -0.50174036939391131], [5.8585858585858581, -0.41195583083086279], [5.9595959595959593, -0.31797166281061867], [6.0606060606060606, -0.22074597455506334], [6.1616161616161618, -0.12126992053716677], [6.2626262626262621, -0.020557596287260064], [6.3636363636363633, 0.080364299670281733], [6.4646464646464645, 0.18046693235991093], [6.5656565656565657, 0.27872981867755725], [6.666666666666667, 0.37415123057121996], [6.7676767676767673, 0.46575840702565169], [6.8686868686868685, 0.55261747074640588], [6.9696969696969697, 0.63384294844890576], [7.0707070707070709, 0.70860679769921819], [7.1717171717171713, 0.77614684828358049], [7.2727272727272725, 0.83577457205225891], [7.3737373737373737, 0.8868821020290788], [7.4747474747474749, 0.92894842923125132], [7.5757575757575752, 0.96154471402682351], [7.6767676767676765, 0.98433865788382358], [7.7777777777777777, 0.9970978909438748], [7.8787878787878789, 0.9996923408861117], [7.9797979797979792, 0.99209555893232282], [8.0808080808080813, 0.97438498947553576], [8.1818181818181817, 0.94674118058335432], [8.282828282828282, 0.9094459434244625], [8.3838383838383841, 0.86287947938178355], [8.4848484848484844, 0.80751650413956255], [8.5858585858585865, 0.74392140825684439], [8.6868686868686869, 0.67274250356226473], [8.7878787878787872, 0.5947054140244975], [8.8888888888888893, 0.51060567847428295], [8.9898989898989896, 0.42130064058860689], [9.0909090909090899, 0.32770070881349983], [9.191919191919192, 0.23076007532505177], [9.2929292929292924, 0.13146698864295842], [9.3939393939393945, 0.03083367906114098], [9.4949494949494948, -0.070113960400646769], [9.5959595959595951, -0.1703468323280965], [9.6969696969696972, -0.26884312591038406], [9.7979797979797976, -0.36459873365588868], [9.8989898989898997, -0.45663748763377376], [10.0, -0.54402111088936977]];",
" var options = {",
" selection: { mode: \"xy\" },",
" legend: { position:\"ne\"},",
" };",
" ",
" var plot1 = $.plot($(\"#placeholder1\"), [ {data:d1}],options);",
" var minx1 = plot1.getAxes().xaxis.min;",
" var maxx1 = plot1.getAxes().xaxis.max;",
" var miny1 = plot1.getAxes().yaxis.min;",
" var maxy1 = plot1.getAxes().yaxis.max;",
" ",
" var iminx1 = plot1.getAxes().xaxis.min;",
" var imaxx1 = plot1.getAxes().xaxis.max;",
" var iminy1 = plot1.getAxes().yaxis.min;",
" var imaxy1 = plot1.getAxes().yaxis.max; ",
" ",
" $(\"#placeholder1\").bind(\"plotselected\", function (event, ranges) {",
" minx1 = ranges.xaxis.from;",
" maxx1 = ranges.xaxis.to;",
" miny1 = ranges.yaxis.from;",
" maxy1 = ranges.yaxis.to;",
" });",
" ",
"",
" $(\"#zoom1\").click(function() {",
" $.plot($(\"#placeholder1\"), plot1.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: minx1 , max: maxx1 },",
" yaxis: { min: miny1 , max: maxy1 }",
" }));",
"",
" });",
" ",
" $(\"#home1\").click(function() {",
" $.plot($(\"#placeholder1\"), plot1.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: iminx1 , max: imaxx1 },",
" yaxis: { min: iminy1 , max: imaxy1 }",
" }));",
"",
" });",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1cbb750>"
]
}
],
"prompt_number": 20
},
{
"cell_type": "code",
"input": [
"plt.plot_figure([x,y],label=[\"bob\",'alice'])"
],
"language": "python",
"outputs": [
{
"html": [
"",
" <div id=\"placeholder2\"\" style=\"width:",
" 600px;height:300px;\"></div>",
" <input id=\"home2\" type=\"button\" value=\"home\"> <input id=\"zoom2\" type=\"button\" value=\"zoom to selection\">",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1cbb1d0>"
]
},
{
"javascript": [
"var d0 =[[0.0, 0], [0.10101010101010101, 1], [0.20202020202020202, 2], [0.30303030303030304, 3], [0.40404040404040403, 4], [0.50505050505050508, 5], [0.60606060606060608, 6], [0.70707070707070707, 7], [0.80808080808080807, 8], [0.90909090909090906, 9], [1.0101010101010102, 10], [1.1111111111111112, 11], [1.2121212121212122, 12], [1.3131313131313131, 13], [1.4141414141414141, 14], [1.5151515151515151, 15], [1.6161616161616161, 16], [1.7171717171717171, 17], [1.8181818181818181, 18], [1.9191919191919191, 19], [2.0202020202020203, 20], [2.1212121212121211, 21], [2.2222222222222223, 22], [2.3232323232323231, 23], [2.4242424242424243, 24], [2.5252525252525251, 25], [2.6262626262626263, 26], [2.7272727272727271, 27], [2.8282828282828283, 28], [2.9292929292929291, 29], [3.0303030303030303, 30], [3.131313131313131, 31], [3.2323232323232323, 32], [3.3333333333333335, 33], [3.4343434343434343, 34], [3.5353535353535355, 35], [3.6363636363636362, 36], [3.7373737373737375, 37], [3.8383838383838382, 38], [3.9393939393939394, 39], [4.0404040404040407, 40], [4.141414141414141, 41], [4.2424242424242422, 42], [4.3434343434343434, 43], [4.4444444444444446, 44], [4.545454545454545, 45], [4.6464646464646462, 46], [4.7474747474747474, 47], [4.8484848484848486, 48], [4.9494949494949498, 49], [5.0505050505050502, 50], [5.1515151515151514, 51], [5.2525252525252526, 52], [5.3535353535353538, 53], [5.4545454545454541, 54], [5.5555555555555554, 55], [5.6565656565656566, 56], [5.7575757575757578, 57], [5.8585858585858581, 58], [5.9595959595959593, 59], [6.0606060606060606, 60], [6.1616161616161618, 61], [6.2626262626262621, 62], [6.3636363636363633, 63], [6.4646464646464645, 64], [6.5656565656565657, 65], [6.666666666666667, 66], [6.7676767676767673, 67], [6.8686868686868685, 68], [6.9696969696969697, 69], [7.0707070707070709, 70], [7.1717171717171713, 71], [7.2727272727272725, 72], [7.3737373737373737, 73], [7.4747474747474749, 74], [7.5757575757575752, 75], [7.6767676767676765, 76], [7.7777777777777777, 77], [7.8787878787878789, 78], [7.9797979797979792, 79], [8.0808080808080813, 80], [8.1818181818181817, 81], [8.282828282828282, 82], [8.3838383838383841, 83], [8.4848484848484844, 84], [8.5858585858585865, 85], [8.6868686868686869, 86], [8.7878787878787872, 87], [8.8888888888888893, 88], [8.9898989898989896, 89], [9.0909090909090899, 90], [9.191919191919192, 91], [9.2929292929292924, 92], [9.3939393939393945, 93], [9.4949494949494948, 94], [9.5959595959595951, 95], [9.6969696969696972, 96], [9.7979797979797976, 97], [9.8989898989898997, 98], [10.0, 99]];",
"var d1 =[[0.0, 0], [0.10083842025810461, 1], [0.20064885652268541, 2], [0.2984138044476411, 3], [0.39313661214832979, 4], [0.48385164043793466, 5], [0.56963410690896565, 6], [0.6496095135057065, 7], [0.72296256147946047, 8], [0.78894546284425737, 9], [0.84688556360298339, 10], [0.89619220102995634, 11], [0.93636272510428475, 12], [0.96698762270929961, 13], [0.98775469236008384, 14], [0.99845222690038948, 15], [0.99897117172335681, 16], [0.98930623651434013, 17], [0.96955594918232368, 18], [0.93992165143013118, 19], [0.90070544620295545, 20], [0.85230711793967517, 21], [0.7952200570230491, 22], [0.73002622997644639, 23], [0.65739024668277546, 24], [0.5780525851065732, 25], [0.49282204258892348, 26], [0.40256749066949654, 27], [0.30820901749007684, 28], [0.21070854807719289, 29], [0.11106003812412972, 30], [0.010279341240534697, 31], [-0.090606147033407733, 32], [-0.19056796287548539, 33], [-0.28858705872043244, 34], [-0.38366419180611233, 35], [-0.47483011082223947, 36], [-0.56115543681520175, 37], [-0.64176013761938777, 38], [-0.71582249922919017, 39], [-0.78258750265420218, 40], [-0.84137452086087006, 41], [-0.89158425733514024, 42], [-0.93270485553183358, 43], [-0.9643171169287782, 44], [-0.98609877449092964, 45], [-0.99782777797921263, 46], [-0.99938455761243572, 47], [-0.99075324300567713, 48], [-0.97202182495883338, 49], [-0.94338125844599963, 50], [-0.90512351595013674, 51], [-0.85763861098805172, 52], [-0.80141062216896974, 53], [-0.73701275831891333, 54], [-0.66510151497882242, 55], [-0.58640998184723514, 56], [-0.50174036939391131, 57], [-0.41195583083086279, 58], [-0.31797166281061867, 59], [-0.22074597455506334, 60], [-0.12126992053716677, 61], [-0.020557596287260064, 62], [0.080364299670281733, 63], [0.18046693235991093, 64], [0.27872981867755725, 65], [0.37415123057121996, 66], [0.46575840702565169, 67], [0.55261747074640588, 68], [0.63384294844890576, 69], [0.70860679769921819, 70], [0.77614684828358049, 71], [0.83577457205225891, 72], [0.8868821020290788, 73], [0.92894842923125132, 74], [0.96154471402682351, 75], [0.98433865788382358, 76], [0.9970978909438748, 77], [0.9996923408861117, 78], [0.99209555893232282, 79], [0.97438498947553576, 80], [0.94674118058335432, 81], [0.9094459434244625, 82], [0.86287947938178355, 83], [0.80751650413956255, 84], [0.74392140825684439, 85], [0.67274250356226473, 86], [0.5947054140244975, 87], [0.51060567847428295, 88], [0.42130064058860689, 89], [0.32770070881349983, 90], [0.23076007532505177, 91], [0.13146698864295842, 92], [0.03083367906114098, 93], [-0.070113960400646769, 94], [-0.1703468323280965, 95], [-0.26884312591038406, 96], [-0.36459873365588868, 97], [-0.45663748763377376, 98], [-0.54402111088936977, 99]];",
"",
" var options = {",
" selection: { mode: \"xy\" },",
" legend: { position:\"ne\"},",
" };",
" ",
" var plot2 = $.plot($(\"#placeholder2\"), [ { label:\"bob\", data:d0 },{ label:\"alice\", data:d1 }],options);",
" var minx2 = plot2.getAxes().xaxis.min;",
" var maxx2 = plot2.getAxes().xaxis.max;",
" var miny2 = plot2.getAxes().yaxis.min;",
" var maxy2 = plot2.getAxes().yaxis.max;",
" ",
" var iminx2 = plot2.getAxes().xaxis.min;",
" var imaxx2 = plot2.getAxes().xaxis.max;",
" var iminy2 = plot2.getAxes().yaxis.min;",
" var imaxy2 = plot2.getAxes().yaxis.max; ",
" ",
" $(\"#placeholder2\").bind(\"plotselected\", function (event, ranges) {",
" minx2 = ranges.xaxis.from;",
" maxx2 = ranges.xaxis.to;",
" miny2 = ranges.yaxis.from;",
" maxy2 = ranges.yaxis.to;",
" });",
" ",
"",
" $(\"#zoom2\").click(function() {",
" $.plot($(\"#placeholder2\"), plot2.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: minx2 , max: maxx2 },",
" yaxis: { min: miny2 , max: maxy2 }",
" }));",
"",
" });",
" ",
" $(\"#home2\").click(function() {",
" $.plot($(\"#placeholder2\"), plot2.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: iminx2 , max: imaxx2 },",
" yaxis: { min: iminy2 , max: imaxy2 }",
" }));",
"",
" });",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1cbb1d0>"
]
}
],
"prompt_number": 21
},
{
"cell_type": "code",
"input": [
"plt.plot_figure([x,x],[y,y**2],label=[\"bob\",'alice'])"
],
"language": "python",
"outputs": [
{
"html": [
"",
" <div id=\"placeholder3\"\" style=\"width:",
" 600px;height:300px;\"></div>",
" <input id=\"home3\" type=\"button\" value=\"home\"> <input id=\"zoom3\" type=\"button\" value=\"zoom to selection\">",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1cbb490>"
]
},
{
"javascript": [
"var d0 =[[0.0, 0.0], [0.10101010101010101, 0.10083842025810461], [0.20202020202020202, 0.20064885652268541], [0.30303030303030304, 0.2984138044476411], [0.40404040404040403, 0.39313661214832979], [0.50505050505050508, 0.48385164043793466], [0.60606060606060608, 0.56963410690896565], [0.70707070707070707, 0.6496095135057065], [0.80808080808080807, 0.72296256147946047], [0.90909090909090906, 0.78894546284425737], [1.0101010101010102, 0.84688556360298339], [1.1111111111111112, 0.89619220102995634], [1.2121212121212122, 0.93636272510428475], [1.3131313131313131, 0.96698762270929961], [1.4141414141414141, 0.98775469236008384], [1.5151515151515151, 0.99845222690038948], [1.6161616161616161, 0.99897117172335681], [1.7171717171717171, 0.98930623651434013], [1.8181818181818181, 0.96955594918232368], [1.9191919191919191, 0.93992165143013118], [2.0202020202020203, 0.90070544620295545], [2.1212121212121211, 0.85230711793967517], [2.2222222222222223, 0.7952200570230491], [2.3232323232323231, 0.73002622997644639], [2.4242424242424243, 0.65739024668277546], [2.5252525252525251, 0.5780525851065732], [2.6262626262626263, 0.49282204258892348], [2.7272727272727271, 0.40256749066949654], [2.8282828282828283, 0.30820901749007684], [2.9292929292929291, 0.21070854807719289], [3.0303030303030303, 0.11106003812412972], [3.131313131313131, 0.010279341240534697], [3.2323232323232323, -0.090606147033407733], [3.3333333333333335, -0.19056796287548539], [3.4343434343434343, -0.28858705872043244], [3.5353535353535355, -0.38366419180611233], [3.6363636363636362, -0.47483011082223947], [3.7373737373737375, -0.56115543681520175], [3.8383838383838382, -0.64176013761938777], [3.9393939393939394, -0.71582249922919017], [4.0404040404040407, -0.78258750265420218], [4.141414141414141, -0.84137452086087006], [4.2424242424242422, -0.89158425733514024], [4.3434343434343434, -0.93270485553183358], [4.4444444444444446, -0.9643171169287782], [4.545454545454545, -0.98609877449092964], [4.6464646464646462, -0.99782777797921263], [4.7474747474747474, -0.99938455761243572], [4.8484848484848486, -0.99075324300567713], [4.9494949494949498, -0.97202182495883338], [5.0505050505050502, -0.94338125844599963], [5.1515151515151514, -0.90512351595013674], [5.2525252525252526, -0.85763861098805172], [5.3535353535353538, -0.80141062216896974], [5.4545454545454541, -0.73701275831891333], [5.5555555555555554, -0.66510151497882242], [5.6565656565656566, -0.58640998184723514], [5.7575757575757578, -0.50174036939391131], [5.8585858585858581, -0.41195583083086279], [5.9595959595959593, -0.31797166281061867], [6.0606060606060606, -0.22074597455506334], [6.1616161616161618, -0.12126992053716677], [6.2626262626262621, -0.020557596287260064], [6.3636363636363633, 0.080364299670281733], [6.4646464646464645, 0.18046693235991093], [6.5656565656565657, 0.27872981867755725], [6.666666666666667, 0.37415123057121996], [6.7676767676767673, 0.46575840702565169], [6.8686868686868685, 0.55261747074640588], [6.9696969696969697, 0.63384294844890576], [7.0707070707070709, 0.70860679769921819], [7.1717171717171713, 0.77614684828358049], [7.2727272727272725, 0.83577457205225891], [7.3737373737373737, 0.8868821020290788], [7.4747474747474749, 0.92894842923125132], [7.5757575757575752, 0.96154471402682351], [7.6767676767676765, 0.98433865788382358], [7.7777777777777777, 0.9970978909438748], [7.8787878787878789, 0.9996923408861117], [7.9797979797979792, 0.99209555893232282], [8.0808080808080813, 0.97438498947553576], [8.1818181818181817, 0.94674118058335432], [8.282828282828282, 0.9094459434244625], [8.3838383838383841, 0.86287947938178355], [8.4848484848484844, 0.80751650413956255], [8.5858585858585865, 0.74392140825684439], [8.6868686868686869, 0.67274250356226473], [8.7878787878787872, 0.5947054140244975], [8.8888888888888893, 0.51060567847428295], [8.9898989898989896, 0.42130064058860689], [9.0909090909090899, 0.32770070881349983], [9.191919191919192, 0.23076007532505177], [9.2929292929292924, 0.13146698864295842], [9.3939393939393945, 0.03083367906114098], [9.4949494949494948, -0.070113960400646769], [9.5959595959595951, -0.1703468323280965], [9.6969696969696972, -0.26884312591038406], [9.7979797979797976, -0.36459873365588868], [9.8989898989898997, -0.45663748763377376], [10.0, -0.54402111088936977]];",
"var d1 =[[0.0, 0.0], [0.10101010101010101, 0.01016838700015012], [0.20202020202020202, 0.040259963623861195], [0.30303030303030304, 0.089050798684914986], [0.40404040404040403, 0.1545563958114663], [0.50505050505050508, 0.2341124099544804], [0.60606060606060608, 0.32448301575397492], [0.70707070707070707, 0.42199252003712068], [0.80808080808080807, 0.52267486530094265], [0.90909090909090906, 0.62243494334253946], [1.0101010101010102, 0.7172151578391428], [1.1111111111111112, 0.80316046118691764], [1.2121212121212122, 0.8767751529647223], [1.3131313131313131, 0.93506506247298282], [1.4141414141414141, 0.97565933227936386], [1.5151515151515151, 0.99690684940234686], [1.6161616161616161, 0.99794340193433639], [1.7171717171717171, 0.97872682960616753], [1.8181818181818181, 0.94003873859483666], [1.9191919191919191, 0.88345271082714505], [2.0202020202020203, 0.81127030081966511], [2.1212121212121211, 0.72642742329063537], [2.2222222222222223, 0.63237493909174147], [2.3232323232323231, 0.53293829645362345], [2.4242424242424243, 0.43216193643364037], [2.5252525252525251, 0.33414479114839207], [2.6262626262626263, 0.24287356566151871], [2.7272727272727271, 0.16206058454393518], [2.8282828282828283, 0.094992798462198491], [2.9292929292929291, 0.044398092232798704], [3.0303030303030303, 0.012334332068133147], [3.131313131313131, 0.00010566485633935741], [3.2323232323232323, 0.0082094738802395012], [3.3333333333333335, 0.036316148474512373], [3.4343434343434343, 0.083282490460910324], [3.5353535353535355, 0.14719821207423736], [3.6363636363636362, 0.22546363414346021], [3.7373737373737375, 0.31489542426725986], [3.8383838383838382, 0.41185607423725551], [3.9393939393939394, 0.51240185040272401], [4.0404040404040407, 0.61244319931054092], [4.141414141414141, 0.70791108435385863], [4.2424242424242422, 0.79492248792785358], [4.3434343434343434, 0.86993834753265853], [4.4444444444444446, 0.92990750200183092], [4.545454545454545, 0.9723907930525133], [4.6464646464646462, 0.99566027450693284], [4.7474747474747474, 0.99876949399420389], [4.8484848484848486, 0.98159198852626628], [4.9494949494949498, 0.94482642819630092], [5.0505050505050502, 0.88996819878715794], [5.1515151515151514, 0.8192485791259374], [5.2525252525252526, 0.73554398705751467], [5.3535353535353538, 0.64225898532525516], [5.4545454545454541, 0.54318780592485294], [5.5555555555555554, 0.44236002522712475], [5.6565656565656566, 0.34387666681007467], [5.7575757575757578, 0.25174339827953857], [5.8585858585858581, 0.16970760655554645], [5.9595959595959593, 0.10110597835054978], [6.0606060606060606, 0.048728785282264674], [6.1616161616161618, 0.014706393627090744], [6.2626262626262621, 0.00042261476510996874], [6.3636363636363633, 0.0064584206614948445], [6.4646464646464645, 0.032568313675396664], [6.5656565656565657, 0.07769031182002395], [6.666666666666667, 0.1399891433379582], [6.7676767676767673, 0.21693089371507263], [6.8686868686868685, 0.30538606897415477], [6.9696969696969697, 0.4017568832984022], [7.0707070707070709, 0.50212359374554072], [7.1717171717171713, 0.60240393010053528], [7.2727272727272725, 0.69851913528913656], [7.3737373737373737, 0.78655986289951729], [7.4747474747474749, 0.86294518417120913], [7.5757575757575752, 0.92456823707292579], [7.6767676767676765, 0.96892259340452702], [7.7777777777777777, 0.99420420412472321], [7.8787878787878789, 0.9993847764263537], [7.9797979797979792, 0.98425359805323798], [8.0808080808080813, 0.94942610771523994], [8.1818181818181817, 0.89631886301236352], [8.282828282828282, 0.82709192401121068], [8.3838383838383841, 0.74456099593817782], [8.4848484848484844, 0.65208290445778017], [8.5858585858585865, 0.55341906166284649], [8.6868686868686869, 0.45258247609922375], [8.7878787878787872, 0.35367452947004901], [8.8888888888888893, 0.26071815889018285], [8.9898989898989896, 0.17749422976037052], [9.0909090909090899, 0.1073877545568702], [9.191919191919192, 0.053250212364023566], [9.2929292929292924, 0.017283569102847757], [9.3939393939393945, 0.00095071576444544378], [9.4949494949494948, 0.0049159674430634629], [9.5959595959595951, 0.029018043284216623], [9.6969696969696972, 0.072276626349266612], [9.7979797979797976, 0.13293223658347766], [9.8989898989898997, 0.20851779511248489], [10.0, 0.29595896909330399]];",
"",
" var options = {",
" selection: { mode: \"xy\" },",
" legend: { position:\"ne\"},",
" };",
" ",
" var plot3 = $.plot($(\"#placeholder3\"), [ { label:\"bob\", data:d0 },{ label:\"alice\", data:d1 }],options);",
" var minx3 = plot3.getAxes().xaxis.min;",
" var maxx3 = plot3.getAxes().xaxis.max;",
" var miny3 = plot3.getAxes().yaxis.min;",
" var maxy3 = plot3.getAxes().yaxis.max;",
" ",
" var iminx3 = plot3.getAxes().xaxis.min;",
" var imaxx3 = plot3.getAxes().xaxis.max;",
" var iminy3 = plot3.getAxes().yaxis.min;",
" var imaxy3 = plot3.getAxes().yaxis.max; ",
" ",
" $(\"#placeholder3\").bind(\"plotselected\", function (event, ranges) {",
" minx3 = ranges.xaxis.from;",
" maxx3 = ranges.xaxis.to;",
" miny3 = ranges.yaxis.from;",
" maxy3 = ranges.yaxis.to;",
" });",
" ",
"",
" $(\"#zoom3\").click(function() {",
" $.plot($(\"#placeholder3\"), plot3.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: minx3 , max: maxx3 },",
" yaxis: { min: miny3 , max: maxy3 }",
" }));",
"",
" });",
" ",
" $(\"#home3\").click(function() {",
" $.plot($(\"#placeholder3\"), plot3.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: iminx3 , max: imaxx3 },",
" yaxis: { min: iminy3 , max: imaxy3 }",
" }));",
"",
" });",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1cbb490>"
]
}
],
"prompt_number": 22
},
{
"cell_type": "markdown",
"source": [
"There are also several adjustable parameters for the plot such as the pixel dimensions and the location of the legend."
]
},
{
"cell_type": "code",
"input": [
"plt.pixelsx = 400",
"plt.pixelsy = 300",
"plt.legendloc ='se'",
"plt.plot_figure(x**2,y,label='alice')"
],
"language": "python",
"outputs": [
{
"html": [
"",
" <div id=\"placeholder4\"\" style=\"width:",
" 400px;height:300px;\"></div>",
" <input id=\"home4\" type=\"button\" value=\"home\"> <input id=\"zoom4\" type=\"button\" value=\"zoom to selection\">",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1cbb1d0>"
]
},
{
"javascript": [
"var d1 = [[0.0, 0.0], [0.010203040506070809, 0.10083842025810461], [0.040812162024283234, 0.20064885652268541], [0.091827364554637289, 0.2984138044476411], [0.16324864809713294, 0.39313661214832979], [0.25507601265177027, 0.48385164043793466], [0.36730945821854916, 0.56963410690896565], [0.49994898479746963, 0.6496095135057065], [0.65299459238853175, 0.72296256147946047], [0.82644628099173545, 0.78894546284425737], [1.0203040506070811, 0.84688556360298339], [1.2345679012345681, 0.89619220102995634], [1.4692378328741966, 0.93636272510428475], [1.7243138455259668, 0.96698762270929961], [1.9997959391898785, 0.98775469236008384], [2.2956841138659319, 0.99845222690038948], [2.611978369554127, 0.99897117172335681], [2.9486787062544635, 0.98930623651434013], [3.3057851239669418, 0.96955594918232368], [3.6832976226915619, 0.93992165143013118], [4.0812162024283243, 0.90070544620295545], [4.4995408631772262, 0.85230711793967517], [4.9382716049382722, 0.7952200570230491], [5.3974084277114578, 0.73002622997644639], [5.8769513314967865, 0.65739024668277546], [6.3769003162942548, 0.5780525851065732], [6.8972553821038671, 0.49282204258892348], [7.438016528925619, 0.40256749066949654], [7.9991837567595141, 0.30820901749007684], [8.5807570656055496, 0.21070854807719289], [9.1827364554637274, 0.11106003812412972], [9.8051219263340457, 0.010279341240534697], [10.447913478216508, -0.090606147033407733], [11.111111111111112, -0.19056796287548539], [11.794714825017854, -0.28858705872043244], [12.498724619936741, -0.38366419180611233], [13.223140495867767, -0.47483011082223947], [13.967962452810939, -0.56115543681520175], [14.733190490766248, -0.64176013761938777], [15.5188246097337, -0.71582249922919017], [16.324864809713297, -0.78258750265420218], [17.151311090705025, -0.84137452086087006], [17.998163452708905, -0.89158425733514024], [18.865421895724925, -0.93270485553183358], [19.753086419753089, -0.9643171169287782], [20.661157024793383, -0.98609877449092964], [21.589633710845831, -0.99782777797921263], [22.538516477910417, -0.99938455761243572], [23.507805325987146, -0.99075324300567713], [24.497500255076016, -0.97202182495883338], [25.507601265177019, -0.94338125844599963], [26.538108356290174, -0.90512351595013674], [27.589021528415469, -0.85763861098805172], [28.660340781552907, -0.80141062216896974], [29.752066115702476, -0.73701275831891333], [30.864197530864196, -0.66510151497882242], [31.996735027038056, -0.58640998184723514], [33.149678604224064, -0.50174036939391131], [34.323028262422199, -0.41195583083086279], [35.51678400163248, -0.31797166281061867], [36.73094582185491, -0.22074597455506334], [37.965513723089479, -0.12126992053716677], [39.220487705336183, -0.020557596287260064], [40.495867768595041, 0.080364299670281733], [41.791653912866032, 0.18046693235991093], [43.107846138149171, 0.27872981867755725], [44.44444444444445, 0.37415123057121996], [45.801448831751856, 0.46575840702565169], [47.178859300071416, 0.55261747074640588], [48.576675849403124, 0.63384294844890576], [49.994898479746965, 0.70860679769921819], [51.433527191102939, 0.77614684828358049], [52.892561983471069, 0.83577457205225891], [54.372002856851338, 0.8868821020290788], [55.871849811243756, 0.92894842923125132], [57.392102846648292, 0.96154471402682351], [58.932761963064991, 0.98433865788382358], [60.493827160493822, 0.9970978909438748], [62.075298438934801, 0.9996923408861117], [63.677175798387907, 0.99209555893232282], [65.299459238853188, 0.97438498947553576], [66.942148760330582, 0.94674118058335432], [68.605244362820102, 0.9094459434244625], [70.288746046321805, 0.86287947938178355], [71.99265381083562, 0.80751650413956255], [73.716967656361604, 0.74392140825684439], [75.4616875828997, 0.67274250356226473], [77.226813590449936, 0.5947054140244975], [79.012345679012356, 0.51060567847428295], [80.818283848586873, 0.42130064058860689], [82.644628099173531, 0.32770070881349983], [84.491378430772372, 0.23076007532505177], [86.358534843383325, 0.13146698864295842], [88.246097337006432, 0.03083367906114098], [90.154065911641666, -0.070113960400646769], [92.082440567289041, -0.1703468323280965], [94.031221303948584, -0.26884312591038406], [96.000408121620239, -0.36459873365588868], [97.990001020304064, -0.45663748763377376], [100.0, -0.54402111088936977]];",
" var options = {",
" selection: { mode: \"xy\" },",
" legend: { position:\"se\"},",
" };",
" ",
" var plot4 = $.plot($(\"#placeholder4\"), [ { label : \"alice\",data:d1}],options);",
" var minx4 = plot4.getAxes().xaxis.min;",
" var maxx4 = plot4.getAxes().xaxis.max;",
" var miny4 = plot4.getAxes().yaxis.min;",
" var maxy4 = plot4.getAxes().yaxis.max;",
" ",
" var iminx4 = plot4.getAxes().xaxis.min;",
" var imaxx4 = plot4.getAxes().xaxis.max;",
" var iminy4 = plot4.getAxes().yaxis.min;",
" var imaxy4 = plot4.getAxes().yaxis.max; ",
" ",
" $(\"#placeholder4\").bind(\"plotselected\", function (event, ranges) {",
" minx4 = ranges.xaxis.from;",
" maxx4 = ranges.xaxis.to;",
" miny4 = ranges.yaxis.from;",
" maxy4 = ranges.yaxis.to;",
" });",
" ",
"",
" $(\"#zoom4\").click(function() {",
" $.plot($(\"#placeholder4\"), plot4.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: minx4 , max: maxx4 },",
" yaxis: { min: miny4 , max: maxy4 }",
" }));",
"",
" });",
" ",
" $(\"#home4\").click(function() {",
" $.plot($(\"#placeholder4\"), plot4.getData(),",
" $.extend(true, {}, options, {",
" xaxis: { min: iminx4 , max: imaxx4 },",
" yaxis: { min: iminy4 , max: imaxy4 }",
" }));",
"",
" });",
" "
],
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1cbb1d0>"
]
}
],
"prompt_number": 23
},
{
"cell_type": "code",
"input": [
""
],
"language": "python",
"outputs": []
}
]
}
]
}
Jump to Line
Something went wrong with that request. Please try again.