Created
June 29, 2012 04:44
-
-
Save crbates/3015819 to your computer and use it in GitHub Desktop.
self contained flot plotting in an ipython notebook
This file contains 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
{ | |
"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 library [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": "markdown", | |
"source": [ | |
"In order to use this it is necessary to load the flot javascript library a minified version of which is contained below:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": true, | |
"input": [ | |
"flot = '''", | |
"/* Javascript plotting library for jQuery, v. 0.7.", | |
" *", | |
" * Released under the MIT license by IOLA, December 2007.", | |
" *", | |
" */", | |
"(function(b){b.color={};b.color.make=function(d,e,g,f){var c={};c.r=d||0;c.g=e||0;c.b=g||0;c.a=f!=null?f:1;c.add=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]+=j}return c.normalize()};c.scale=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]*=j}return c.normalize()};c.toString=function(){if(c.a>=1){return\"rgb(\"+[c.r,c.g,c.b].join(\",\")+\")\"}else{return\"rgba(\"+[c.r,c.g,c.b,c.a].join(\",\")+\")\"}};c.normalize=function(){function h(k,j,l){return j<k?k:(j>l?l:j)}c.r=h(0,parseInt(c.r),255);c.g=h(0,parseInt(c.g),255);c.b=h(0,parseInt(c.b),255);c.a=h(0,c.a,1);return c};c.clone=function(){return b.color.make(c.r,c.b,c.g,c.a)};return c.normalize()};b.color.extract=function(d,e){var c;do{c=d.css(e).toLowerCase();if(c!=\"\"&&c!=\"transparent\"){break}d=d.parent()}while(!b.nodeName(d.get(0),\"body\"));if(c==\"rgba(0, 0, 0, 0)\"){c=\"transparent\"}return b.color.parse(c)};b.color.parse=function(c){var d,f=b.color.make;if(d=/rgb\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10))}if(d=/rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10),parseFloat(d[4]))}if(d=/rgb\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55)}if(d=/rgba\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55,parseFloat(d[4]))}if(d=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c)){return f(parseInt(d[1],16),parseInt(d[2],16),parseInt(d[3],16))}if(d=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c)){return f(parseInt(d[1]+d[1],16),parseInt(d[2]+d[2],16),parseInt(d[3]+d[3],16))}var e=b.trim(c).toLowerCase();if(e==\"transparent\"){return f(255,255,255,0)}else{d=a[e]||[0,0,0];return f(d[0],d[1],d[2])}};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function(c){function b(av,ai,J,af){var Q=[],O={colors:[\"#edc240\",\"#afd8f8\",\"#cb4b4b\",\"#4da74d\",\"#9440ed\"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:\"#ccc\",container:null,position:\"ne\",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{show:null,position:\"bottom\",mode:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:false},yaxis:{autoscaleMargin:0.02,position:\"left\"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:\"#ffffff\",symbol:\"circle\"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:\"left\",horizontal:false},shadowSize:3},grid:{show:true,aboveData:false,color:\"#545454\",backgroundColor:null,borderColor:null,tickColor:null,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:\"#f4f4f4\",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},hooks:{}},az=null,ad=null,y=null,H=null,A=null,p=[],aw=[],q={left:0,right:0,top:0,bottom:0},G=0,I=0,h=0,w=0,ak={processOptions:[],processRawData:[],processDatapoints:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},aq=this;aq.setData=aj;aq.setupGrid=t;aq.draw=W;aq.getPlaceholder=function(){return av};aq.getCanvas=function(){return az};aq.getPlotOffset=function(){return q};aq.width=function(){return h};aq.height=function(){return w};aq.offset=function(){var aB=y.offset();aB.left+=q.left;aB.top+=q.top;return aB};aq.getData=function(){return Q};aq.getAxes=function(){var aC={},aB;c.each(p.concat(aw),function(aD,aE){if(aE){aC[aE.direction+(aE.n!=1?aE.n:\"\")+\"axis\"]=aE}});return aC};aq.getXAxes=function(){return p};aq.getYAxes=function(){return aw};aq.c2p=C;aq.p2c=ar;aq.getOptions=function(){return O};aq.highlight=x;aq.unhighlight=T;aq.triggerRedrawOverlay=f;aq.pointOffset=function(aB){return{left:parseInt(p[aA(aB,\"x\")-1].p2c(+aB.x)+q.left),top:parseInt(aw[aA(aB,\"y\")-1].p2c(+aB.y)+q.top)}};aq.shutdown=ag;aq.resize=function(){B();g(az);g(ad)};aq.hooks=ak;F(aq);Z(J);X();aj(ai);t();W();ah();function an(aD,aB){aB=[aq].concat(aB);for(var aC=0;aC<aD.length;++aC){aD[aC].apply(this,aB)}}function F(){for(var aB=0;aB<af.length;++aB){var aC=af[aB];aC.init(aq);if(aC.options){c.extend(true,O,aC.options)}}}function Z(aC){var aB;c.extend(true,O,aC);if(O.xaxis.color==null){O.xaxis.color=O.grid.color}if(O.yaxis.color==null){O.yaxis.color=O.grid.color}if(O.xaxis.tickColor==null){O.xaxis.tickColor=O.grid.tickColor}if(O.yaxis.tickColor==null){O.yaxis.tickColor=O.grid.tickColor}if(O.grid.borderColor==null){O.grid.borderColor=O.grid.color}if(O.grid.tickColor==null){O.grid.tickColor=c.color.parse(O.grid.color).scale(\"a\",0.22).toString()}for(aB=0;aB<Math.max(1,O.xaxes.length);++aB){O.xaxes[aB]=c.extend(true,{},O.xaxis,O.xaxes[aB])}for(aB=0;aB<Math.max(1,O.yaxes.length);++aB){O.yaxes[aB]=c.extend(true,{},O.yaxis,O.yaxes[aB])}if(O.xaxis.noTicks&&O.xaxis.ticks==null){O.xaxis.ticks=O.xaxis.noTicks}if(O.yaxis.noTicks&&O.yaxis.ticks==null){O.yaxis.ticks=O.yaxis.noTicks}if(O.x2axis){O.xaxes[1]=c.extend(true,{},O.xaxis,O.x2axis);O.xaxes[1].position=\"top\"}if(O.y2axis){O.yaxes[1]=c.extend(true,{},O.yaxis,O.y2axis);O.yaxes[1].position=\"right\"}if(O.grid.coloredAreas){O.grid.markings=O.grid.coloredAreas}if(O.grid.coloredAreasColor){O.grid.markingsColor=O.grid.coloredAreasColor}if(O.lines){c.extend(true,O.series.lines,O.lines)}if(O.points){c.extend(true,O.series.points,O.points)}if(O.bars){c.extend(true,O.series.bars,O.bars)}if(O.shadowSize!=null){O.series.shadowSize=O.shadowSize}for(aB=0;aB<O.xaxes.length;++aB){V(p,aB+1).options=O.xaxes[aB]}for(aB=0;aB<O.yaxes.length;++aB){V(aw,aB+1).options=O.yaxes[aB]}for(var aD in ak){if(O.hooks[aD]&&O.hooks[aD].length){ak[aD]=ak[aD].concat(O.hooks[aD])}}an(ak.processOptions,[O])}function aj(aB){Q=Y(aB);ax();z()}function Y(aE){var aC=[];for(var aB=0;aB<aE.length;++aB){var aD=c.extend(true,{},O.series);if(aE[aB].data!=null){aD.data=aE[aB].data;delete aE[aB].data;c.extend(true,aD,aE[aB]);aE[aB].data=aD.data}else{aD.data=aE[aB]}aC.push(aD)}return aC}function aA(aC,aD){var aB=aC[aD+\"axis\"];if(typeof aB==\"object\"){aB=aB.n}if(typeof aB!=\"number\"){aB=1}return aB}function m(){return c.grep(p.concat(aw),function(aB){return aB})}function C(aE){var aC={},aB,aD;for(aB=0;aB<p.length;++aB){aD=p[aB];if(aD&&aD.used){aC[\"x\"+aD.n]=aD.c2p(aE.left)}}for(aB=0;aB<aw.length;++aB){aD=aw[aB];if(aD&&aD.used){aC[\"y\"+aD.n]=aD.c2p(aE.top)}}if(aC.x1!==undefined){aC.x=aC.x1}if(aC.y1!==undefined){aC.y=aC.y1}return aC}function ar(aF){var aD={},aC,aE,aB;for(aC=0;aC<p.length;++aC){aE=p[aC];if(aE&&aE.used){aB=\"x\"+aE.n;if(aF[aB]==null&&aE.n==1){aB=\"x\"}if(aF[aB]!=null){aD.left=aE.p2c(aF[aB]);break}}}for(aC=0;aC<aw.length;++aC){aE=aw[aC];if(aE&&aE.used){aB=\"y\"+aE.n;if(aF[aB]==null&&aE.n==1){aB=\"y\"}if(aF[aB]!=null){aD.top=aE.p2c(aF[aB]);break}}}return aD}function V(aC,aB){if(!aC[aB-1]){aC[aB-1]={n:aB,direction:aC==p?\"x\":\"y\",options:c.extend(true,{},aC==p?O.xaxis:O.yaxis)}}return aC[aB-1]}function ax(){var aG;var aM=Q.length,aB=[],aE=[];for(aG=0;aG<Q.length;++aG){var aJ=Q[aG].color;if(aJ!=null){--aM;if(typeof aJ==\"number\"){aE.push(aJ)}else{aB.push(c.color.parse(Q[aG].color))}}}for(aG=0;aG<aE.length;++aG){aM=Math.max(aM,aE[aG]+1)}var aC=[],aF=0;aG=0;while(aC.length<aM){var aI;if(O.colors.length==aG){aI=c.color.make(100,100,100)}else{aI=c.color.parse(O.colors[aG])}var aD=aF%2==1?-1:1;aI.scale(\"rgb\",1+aD*Math.ceil(aF/2)*0.2);aC.push(aI);++aG;if(aG>=O.colors.length){aG=0;++aF}}var aH=0,aN;for(aG=0;aG<Q.length;++aG){aN=Q[aG];if(aN.color==null){aN.color=aC[aH].toString();++aH}else{if(typeof aN.color==\"number\"){aN.color=aC[aN.color].toString()}}if(aN.lines.show==null){var aL,aK=true;for(aL in aN){if(aN[aL]&&aN[aL].show){aK=false;break}}if(aK){aN.lines.show=true}}aN.xaxis=V(p,aA(aN,\"x\"));aN.yaxis=V(aw,aA(aN,\"y\"))}}function z(){var aO=Number.POSITIVE_INFINITY,aI=Number.NEGATIVE_INFINITY,aB=Number.MAX_VALUE,aU,aS,aR,aN,aD,aJ,aT,aP,aH,aG,aC,a0,aX,aL;function aF(a3,a2,a1){if(a2<a3.datamin&&a2!=-aB){a3.datamin=a2}if(a1>a3.datamax&&a1!=aB){a3.datamax=a1}}c.each(m(),function(a1,a2){a2.datamin=aO;a2.datamax=aI;a2.used=false});for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aJ.datapoints={points:[]};an(ak.processRawData,[aJ,aJ.data,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];var aZ=aJ.data,aW=aJ.datapoints.format;if(!aW){aW=[];aW.push({x:true,number:true,required:true});aW.push({y:true,number:true,required:true});if(aJ.bars.show||(aJ.lines.show&&aJ.lines.fill)){aW.push({y:true,number:true,required:false,defaultValue:0});if(aJ.bars.horizontal){delete aW[aW.length-1].y;aW[aW.length-1].x=true}}aJ.datapoints.format=aW}if(aJ.datapoints.pointsize!=null){continue}aJ.datapoints.pointsize=aW.length;aP=aJ.datapoints.pointsize;aT=aJ.datapoints.points;insertSteps=aJ.lines.show&&aJ.lines.steps;aJ.xaxis.used=aJ.yaxis.used=true;for(aS=aR=0;aS<aZ.length;++aS,aR+=aP){aL=aZ[aS];var aE=aL==null;if(!aE){for(aN=0;aN<aP;++aN){a0=aL[aN];aX=aW[aN];if(aX){if(aX.number&&a0!=null){a0=+a0;if(isNaN(a0)){a0=null}else{if(a0==Infinity){a0=aB}else{if(a0==-Infinity){a0=-aB}}}}if(a0==null){if(aX.required){aE=true}if(aX.defaultValue!=null){a0=aX.defaultValue}}}aT[aR+aN]=a0}}if(aE){for(aN=0;aN<aP;++aN){a0=aT[aR+aN];if(a0!=null){aX=aW[aN];if(aX.x){aF(aJ.xaxis,a0,a0)}if(aX.y){aF(aJ.yaxis,a0,a0)}}aT[aR+aN]=null}}else{if(insertSteps&&aR>0&&aT[aR-aP]!=null&&aT[aR-aP]!=aT[aR]&&aT[aR-aP+1]!=aT[aR+1]){for(aN=0;aN<aP;++aN){aT[aR+aP+aN]=aT[aR+aN]}aT[aR+1]=aT[aR-aP+1];aR+=aP}}}}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];an(ak.processDatapoints,[aJ,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aT=aJ.datapoints.points,aP=aJ.datapoints.pointsize;var aK=aO,aQ=aO,aM=aI,aV=aI;for(aS=0;aS<aT.length;aS+=aP){if(aT[aS]==null){continue}for(aN=0;aN<aP;++aN){a0=aT[aS+aN];aX=aW[aN];if(!aX||a0==aB||a0==-aB){continue}if(aX.x){if(a0<aK){aK=a0}if(a0>aM){aM=a0}}if(aX.y){if(a0<aQ){aQ=a0}if(a0>aV){aV=a0}}}}if(aJ.bars.show){var aY=aJ.bars.align==\"left\"?0:-aJ.bars.barWidth/2;if(aJ.bars.horizontal){aQ+=aY;aV+=aY+aJ.bars.barWidth}else{aK+=aY;aM+=aY+aJ.bars.barWidth}}aF(aJ.xaxis,aK,aM);aF(aJ.yaxis,aQ,aV)}c.each(m(),function(a1,a2){if(a2.datamin==aO){a2.datamin=null}if(a2.datamax==aI){a2.datamax=null}})}function j(aB,aC){var aD=document.createElement(\"canvas\");aD.className=aC;aD.width=G;aD.height=I;if(!aB){c(aD).css({position:\"absolute\",left:0,top:0})}c(aD).appendTo(av);if(!aD.getContext){aD=window.G_vmlCanvasManager.initElement(aD)}aD.getContext(\"2d\").save();return aD}function B(){G=av.width();I=av.height();if(G<=0||I<=0){throw\"Invalid dimensions for plot, width = \"+G+\", height = \"+I}}function g(aC){if(aC.width!=G){aC.width=G}if(aC.height!=I){aC.height=I}var aB=aC.getContext(\"2d\");aB.restore();aB.save()}function X(){var aC,aB=av.children(\"canvas.base\"),aD=av.children(\"canvas.overlay\");if(aB.length==0||aD==0){av.html(\"\");av.css({padding:0});if(av.css(\"position\")==\"static\"){av.css(\"position\",\"relative\")}B();az=j(true,\"base\");ad=j(false,\"overlay\");aC=false}else{az=aB.get(0);ad=aD.get(0);aC=true}H=az.getContext(\"2d\");A=ad.getContext(\"2d\");y=c([ad,az]);if(aC){av.data(\"plot\").shutdown();aq.resize();A.clearRect(0,0,G,I);y.unbind();av.children().not([az,ad]).remove()}av.data(\"plot\",aq)}function ah(){if(O.grid.hoverable){y.mousemove(aa);y.mouseleave(l)}if(O.grid.clickable){y.click(R)}an(ak.bindEvents,[y])}function ag(){if(M){clearTimeout(M)}y.unbind(\"mousemove\",aa);y.unbind(\"mouseleave\",l);y.unbind(\"click\",R);an(ak.shutdown,[y])}function r(aG){function aC(aH){return aH}var aF,aB,aD=aG.options.transform||aC,aE=aG.options.inverseTransform;if(aG.direction==\"x\"){aF=aG.scale=h/Math.abs(aD(aG.max)-aD(aG.min));aB=Math.min(aD(aG.max),aD(aG.min))}else{aF=aG.scale=w/Math.abs(aD(aG.max)-aD(aG.min));aF=-aF;aB=Math.max(aD(aG.max),aD(aG.min))}if(aD==aC){aG.p2c=function(aH){return(aH-aB)*aF}}else{aG.p2c=function(aH){return(aD(aH)-aB)*aF}}if(!aE){aG.c2p=function(aH){return aB+aH/aF}}else{aG.c2p=function(aH){return aE(aB+aH/aF)}}}function L(aD){var aB=aD.options,aF,aJ=aD.ticks||[],aI=[],aE,aK=aB.labelWidth,aG=aB.labelHeight,aC;function aH(aM,aL){return c('<div style=\"position:absolute;top:-10000px;'+aL+'font-size:smaller\"><div class=\"'+aD.direction+\"Axis \"+aD.direction+aD.n+'Axis\">'+aM.join(\"\")+\"</div></div>\").appendTo(av)}if(aD.direction==\"x\"){if(aK==null){aK=Math.floor(G/(aJ.length>0?aJ.length:1))}if(aG==null){aI=[];for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class=\"tickLabel\" style=\"float:left;width:'+aK+'px\">'+aE+\"</div>\")}}if(aI.length>0){aI.push('<div style=\"clear:left\"></div>');aC=aH(aI,\"width:10000px;\");aG=aC.height();aC.remove()}}}else{if(aK==null||aG==null){for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class=\"tickLabel\">'+aE+\"</div>\")}}if(aI.length>0){aC=aH(aI,\"\");if(aK==null){aK=aC.children().width()}if(aG==null){aG=aC.find(\"div.tickLabel\").height()}aC.remove()}}}if(aK==null){aK=0}if(aG==null){aG=0}aD.labelWidth=aK;aD.labelHeight=aG}function au(aD){var aC=aD.labelWidth,aL=aD.labelHeight,aH=aD.options.position,aF=aD.options.tickLength,aG=O.grid.axisMargin,aJ=O.grid.labelMargin,aK=aD.direction==\"x\"?p:aw,aE;var aB=c.grep(aK,function(aN){return aN&&aN.options.position==aH&&aN.reserveSpace});if(c.inArray(aD,aB)==aB.length-1){aG=0}if(aF==null){aF=\"full\"}var aI=c.grep(aK,function(aN){return aN&&aN.reserveSpace});var aM=c.inArray(aD,aI)==0;if(!aM&&aF==\"full\"){aF=5}if(!isNaN(+aF)){aJ+=+aF}if(aD.direction==\"x\"){aL+=aJ;if(aH==\"bottom\"){q.bottom+=aL+aG;aD.box={top:I-q.bottom,height:aL}}else{aD.box={top:q.top+aG,height:aL};q.top+=aL+aG}}else{aC+=aJ;if(aH==\"left\"){aD.box={left:q.left+aG,width:aC};q.left+=aC+aG}else{q.right+=aC+aG;aD.box={left:G-q.right,width:aC}}}aD.position=aH;aD.tickLength=aF;aD.box.padding=aJ;aD.innermost=aM}function U(aB){if(aB.direction==\"x\"){aB.box.left=q.left;aB.box.width=h}else{aB.box.top=q.top;aB.box.height=w}}function t(){var aC,aE=m();c.each(aE,function(aF,aG){aG.show=aG.options.show;if(aG.show==null){aG.show=aG.used}aG.reserveSpace=aG.show||aG.options.reserveSpace;n(aG)});allocatedAxes=c.grep(aE,function(aF){return aF.reserveSpace});q.left=q.right=q.top=q.bottom=0;if(O.grid.show){c.each(allocatedAxes,function(aF,aG){S(aG);P(aG);ap(aG,aG.ticks);L(aG)});for(aC=allocatedAxes.length-1;aC>=0;--aC){au(allocatedAxes[aC])}var aD=O.grid.minBorderMargin;if(aD==null){aD=0;for(aC=0;aC<Q.length;++aC){aD=Math.max(aD,Q[aC].points.radius+Q[aC].points.lineWidth/2)}}for(var aB in q){q[aB]+=O.grid.borderWidth;q[aB]=Math.max(aD,q[aB])}}h=G-q.left-q.right;w=I-q.bottom-q.top;c.each(aE,function(aF,aG){r(aG)});if(O.grid.show){c.each(allocatedAxes,function(aF,aG){U(aG)});k()}o()}function n(aE){var aF=aE.options,aD=+(aF.min!=null?aF.min:aE.datamin),aB=+(aF.max!=null?aF.max:aE.datamax),aH=aB-aD;if(aH==0){var aC=aB==0?1:0.01;if(aF.min==null){aD-=aC}if(aF.max==null||aF.min!=null){aB+=aC}}else{var aG=aF.autoscaleMargin;if(aG!=null){if(aF.min==null){aD-=aH*aG;if(aD<0&&aE.datamin!=null&&aE.datamin>=0){aD=0}}if(aF.max==null){aB+=aH*aG;if(aB>0&&aE.datamax!=null&&aE.datamax<=0){aB=0}}}}aE.min=aD;aE.max=aB}function S(aG){var aM=aG.options;var aH;if(typeof aM.ticks==\"number\"&&aM.ticks>0){aH=aM.ticks}else{aH=0.3*Math.sqrt(aG.direction==\"x\"?G:I)}var aT=(aG.max-aG.min)/aH,aO,aB,aN,aR,aS,aQ,aI;if(aM.mode==\"time\"){var aJ={second:1000,minute:60*1000,hour:60*60*1000,day:24*60*60*1000,month:30*24*60*60*1000,year:365.2425*24*60*60*1000};var aK=[[1,\"second\"],[2,\"second\"],[5,\"second\"],[10,\"second\"],[30,\"second\"],[1,\"minute\"],[2,\"minute\"],[5,\"minute\"],[10,\"minute\"],[30,\"minute\"],[1,\"hour\"],[2,\"hour\"],[4,\"hour\"],[8,\"hour\"],[12,\"hour\"],[1,\"day\"],[2,\"day\"],[3,\"day\"],[0.25,\"month\"],[0.5,\"month\"],[1,\"month\"],[2,\"month\"],[3,\"month\"],[6,\"month\"],[1,\"year\"]];var aC=0;if(aM.minTickSize!=null){if(typeof aM.tickSize==\"number\"){aC=aM.tickSize}else{aC=aM.minTickSize[0]*aJ[aM.minTickSize[1]]}}for(var aS=0;aS<aK.length-1;++aS){if(aT<(aK[aS][0]*aJ[aK[aS][1]]+aK[aS+1][0]*aJ[aK[aS+1][1]])/2&&aK[aS][0]*aJ[aK[aS][1]]>=aC){break}}aO=aK[aS][0];aN=aK[aS][1];if(aN==\"year\"){aQ=Math.pow(10,Math.floor(Math.log(aT/aJ.year)/Math.LN10));aI=(aT/aJ.year)/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ}aG.tickSize=aM.tickSize||[aO,aN];aB=function(aX){var a2=[],a0=aX.tickSize[0],a3=aX.tickSize[1],a1=new Date(aX.min);var aW=a0*aJ[a3];if(a3==\"second\"){a1.setUTCSeconds(a(a1.getUTCSeconds(),a0))}if(a3==\"minute\"){a1.setUTCMinutes(a(a1.getUTCMinutes(),a0))}if(a3==\"hour\"){a1.setUTCHours(a(a1.getUTCHours(),a0))}if(a3==\"month\"){a1.setUTCMonth(a(a1.getUTCMonth(),a0))}if(a3==\"year\"){a1.setUTCFullYear(a(a1.getUTCFullYear(),a0))}a1.setUTCMilliseconds(0);if(aW>=aJ.minute){a1.setUTCSeconds(0)}if(aW>=aJ.hour){a1.setUTCMinutes(0)}if(aW>=aJ.day){a1.setUTCHours(0)}if(aW>=aJ.day*4){a1.setUTCDate(1)}if(aW>=aJ.year){a1.setUTCMonth(0)}var a5=0,a4=Number.NaN,aY;do{aY=a4;a4=a1.getTime();a2.push(a4);if(a3==\"month\"){if(a0<1){a1.setUTCDate(1);var aV=a1.getTime();a1.setUTCMonth(a1.getUTCMonth()+1);var aZ=a1.getTime();a1.setTime(a4+a5*aJ.hour+(aZ-aV)*a0);a5=a1.getUTCHours();a1.setUTCHours(0)}else{a1.setUTCMonth(a1.getUTCMonth()+a0)}}else{if(a3==\"year\"){a1.setUTCFullYear(a1.getUTCFullYear()+a0)}else{a1.setTime(a4+aW)}}}while(a4<aX.max&&a4!=aY);return a2};aR=function(aV,aY){var a0=new Date(aV);if(aM.timeformat!=null){return c.plot.formatDate(a0,aM.timeformat,aM.monthNames)}var aW=aY.tickSize[0]*aJ[aY.tickSize[1]];var aX=aY.max-aY.min;var aZ=(aM.twelveHourClock)?\" %p\":\"\";if(aW<aJ.minute){fmt=\"%h:%M:%S\"+aZ}else{if(aW<aJ.day){if(aX<2*aJ.day){fmt=\"%h:%M\"+aZ}else{fmt=\"%b %d %h:%M\"+aZ}}else{if(aW<aJ.month){fmt=\"%b %d\"}else{if(aW<aJ.year){if(aX<aJ.year){fmt=\"%b\"}else{fmt=\"%b %y\"}}else{fmt=\"%y\"}}}}return c.plot.formatDate(a0,fmt,aM.monthNames)}}else{var aU=aM.tickDecimals;var aP=-Math.floor(Math.log(aT)/Math.LN10);if(aU!=null&&aP>aU){aP=aU}aQ=Math.pow(10,-aP);aI=aT/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2;if(aI>2.25&&(aU==null||aP+1<=aU)){aO=2.5;++aP}}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ;if(aM.minTickSize!=null&&aO<aM.minTickSize){aO=aM.minTickSize}aG.tickDecimals=Math.max(0,aU!=null?aU:aP);aG.tickSize=aM.tickSize||aO;aB=function(aX){var aZ=[];var a0=a(aX.min,aX.tickSize),aW=0,aV=Number.NaN,aY;do{aY=aV;aV=a0+aW*aX.tickSize;aZ.push(aV);++aW}while(aV<aX.max&&aV!=aY);return aZ};aR=function(aV,aW){return aV.toFixed(aW.tickDecimals)}}if(aM.alignTicksWithAxis!=null){var aF=(aG.direction==\"x\"?p:aw)[aM.alignTicksWithAxis-1];if(aF&&aF.used&&aF!=aG){var aL=aB(aG);if(aL.length>0){if(aM.min==null){aG.min=Math.min(aG.min,aL[0])}if(aM.max==null&&aL.length>1){aG.max=Math.max(aG.max,aL[aL.length-1])}}aB=function(aX){var aY=[],aV,aW;for(aW=0;aW<aF.ticks.length;++aW){aV=(aF.ticks[aW].v-aF.min)/(aF.max-aF.min);aV=aX.min+aV*(aX.max-aX.min);aY.push(aV)}return aY};if(aG.mode!=\"time\"&&aM.tickDecimals==null){var aE=Math.max(0,-Math.floor(Math.log(aT)/Math.LN10)+1),aD=aB(aG);if(!(aD.length>1&&/\\..*0$/.test((aD[1]-aD[0]).toFixed(aE)))){aG.tickDecimals=aE}}}}aG.tickGenerator=aB;if(c.isFunction(aM.tickFormatter)){aG.tickFormatter=function(aV,aW){return\"\"+aM.tickFormatter(aV,aW)}}else{aG.tickFormatter=aR}}function P(aF){var aH=aF.options.ticks,aG=[];if(aH==null||(typeof aH==\"number\"&&aH>0)){aG=aF.tickGenerator(aF)}else{if(aH){if(c.isFunction(aH)){aG=aH({min:aF.min,max:aF.max})}else{aG=aH}}}var aE,aB;aF.ticks=[];for(aE=0;aE<aG.length;++aE){var aC=null;var aD=aG[aE];if(typeof aD==\"object\"){aB=+aD[0];if(aD.length>1){aC=aD[1]}}else{aB=+aD}if(aC==null){aC=aF.tickFormatter(aB,aF)}if(!isNaN(aB)){aF.ticks.push({v:aB,label:aC})}}}function ap(aB,aC){if(aB.options.autoscaleMargin&&aC.length>0){if(aB.options.min==null){aB.min=Math.min(aB.min,aC[0].v)}if(aB.options.max==null&&aC.length>1){aB.max=Math.max(aB.max,aC[aC.length-1].v)}}}function W(){H.clearRect(0,0,G,I);var aC=O.grid;if(aC.show&&aC.backgroundColor){N()}if(aC.show&&!aC.aboveData){ac()}for(var aB=0;aB<Q.length;++aB){an(ak.drawSeries,[H,Q[aB]]);d(Q[aB])}an(ak.draw,[H]);if(aC.show&&aC.aboveData){ac()}}function D(aB,aI){var aE,aH,aG,aD,aF=m();for(i=0;i<aF.length;++i){aE=aF[i];if(aE.direction==aI){aD=aI+aE.n+\"axis\";if(!aB[aD]&&aE.n==1){aD=aI+\"axis\"}if(aB[aD]){aH=aB[aD].from;aG=aB[aD].to;break}}}if(!aB[aD]){aE=aI==\"x\"?p[0]:aw[0];aH=aB[aI+\"1\"];aG=aB[aI+\"2\"]}if(aH!=null&&aG!=null&&aH>aG){var aC=aH;aH=aG;aG=aC}return{from:aH,to:aG,axis:aE}}function N(){H.save();H.translate(q.left,q.top);H.fillStyle=am(O.grid.backgroundColor,w,0,\"rgba(255, 255, 255, 0)\");H.fillRect(0,0,h,w);H.restore()}function ac(){var aF;H.save();H.translate(q.left,q.top);var aH=O.grid.markings;if(aH){if(c.isFunction(aH)){var aK=aq.getAxes();aK.xmin=aK.xaxis.min;aK.xmax=aK.xaxis.max;aK.ymin=aK.yaxis.min;aK.ymax=aK.yaxis.max;aH=aH(aK)}for(aF=0;aF<aH.length;++aF){var aD=aH[aF],aC=D(aD,\"x\"),aI=D(aD,\"y\");if(aC.from==null){aC.from=aC.axis.min}if(aC.to==null){aC.to=aC.axis.max}if(aI.from==null){aI.from=aI.axis.min}if(aI.to==null){aI.to=aI.axis.max}if(aC.to<aC.axis.min||aC.from>aC.axis.max||aI.to<aI.axis.min||aI.from>aI.axis.max){continue}aC.from=Math.max(aC.from,aC.axis.min);aC.to=Math.min(aC.to,aC.axis.max);aI.from=Math.max(aI.from,aI.axis.min);aI.to=Math.min(aI.to,aI.axis.max);if(aC.from==aC.to&&aI.from==aI.to){continue}aC.from=aC.axis.p2c(aC.from);aC.to=aC.axis.p2c(aC.to);aI.from=aI.axis.p2c(aI.from);aI.to=aI.axis.p2c(aI.to);if(aC.from==aC.to||aI.from==aI.to){H.beginPath();H.strokeStyle=aD.color||O.grid.markingsColor;H.lineWidth=aD.lineWidth||O.grid.markingsLineWidth;H.moveTo(aC.from,aI.from);H.lineTo(aC.to,aI.to);H.stroke()}else{H.fillStyle=aD.color||O.grid.markingsColor;H.fillRect(aC.from,aI.to,aC.to-aC.from,aI.from-aI.to)}}}var aK=m(),aM=O.grid.borderWidth;for(var aE=0;aE<aK.length;++aE){var aB=aK[aE],aG=aB.box,aQ=aB.tickLength,aN,aL,aP,aJ;if(!aB.show||aB.ticks.length==0){continue}H.strokeStyle=aB.options.tickColor||c.color.parse(aB.options.color).scale(\"a\",0.22).toString();H.lineWidth=1;if(aB.direction==\"x\"){aN=0;if(aQ==\"full\"){aL=(aB.position==\"top\"?0:w)}else{aL=aG.top-q.top+(aB.position==\"top\"?aG.height:0)}}else{aL=0;if(aQ==\"full\"){aN=(aB.position==\"left\"?0:h)}else{aN=aG.left-q.left+(aB.position==\"left\"?aG.width:0)}}if(!aB.innermost){H.beginPath();aP=aJ=0;if(aB.direction==\"x\"){aP=h}else{aJ=w}if(H.lineWidth==1){aN=Math.floor(aN)+0.5;aL=Math.floor(aL)+0.5}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ);H.stroke()}H.beginPath();for(aF=0;aF<aB.ticks.length;++aF){var aO=aB.ticks[aF].v;aP=aJ=0;if(aO<aB.min||aO>aB.max||(aQ==\"full\"&&aM>0&&(aO==aB.min||aO==aB.max))){continue}if(aB.direction==\"x\"){aN=aB.p2c(aO);aJ=aQ==\"full\"?-w:aQ;if(aB.position==\"top\"){aJ=-aJ}}else{aL=aB.p2c(aO);aP=aQ==\"full\"?-h:aQ;if(aB.position==\"left\"){aP=-aP}}if(H.lineWidth==1){if(aB.direction==\"x\"){aN=Math.floor(aN)+0.5}else{aL=Math.floor(aL)+0.5}}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ)}H.stroke()}if(aM){H.lineWidth=aM;H.strokeStyle=O.grid.borderColor;H.strokeRect(-aM/2,-aM/2,h+aM,w+aM)}H.restore()}function k(){av.find(\".tickLabels\").remove();var aG=['<div class=\"tickLabels\" style=\"font-size:smaller\">'];var aJ=m();for(var aD=0;aD<aJ.length;++aD){var aC=aJ[aD],aF=aC.box;if(!aC.show){continue}aG.push('<div class=\"'+aC.direction+\"Axis \"+aC.direction+aC.n+'Axis\" style=\"color:'+aC.options.color+'\">');for(var aE=0;aE<aC.ticks.length;++aE){var aH=aC.ticks[aE];if(!aH.label||aH.v<aC.min||aH.v>aC.max){continue}var aK={},aI;if(aC.direction==\"x\"){aI=\"center\";aK.left=Math.round(q.left+aC.p2c(aH.v)-aC.labelWidth/2);if(aC.position==\"bottom\"){aK.top=aF.top+aF.padding}else{aK.bottom=I-(aF.top+aF.height-aF.padding)}}else{aK.top=Math.round(q.top+aC.p2c(aH.v)-aC.labelHeight/2);if(aC.position==\"left\"){aK.right=G-(aF.left+aF.width-aF.padding);aI=\"right\"}else{aK.left=aF.left+aF.padding;aI=\"left\"}}aK.width=aC.labelWidth;var aB=[\"position:absolute\",\"text-align:\"+aI];for(var aL in aK){aB.push(aL+\":\"+aK[aL]+\"px\")}aG.push('<div class=\"tickLabel\" style=\"'+aB.join(\";\")+'\">'+aH.label+\"</div>\")}aG.push(\"</div>\")}aG.push(\"</div>\");av.append(aG.join(\"\"))}function d(aB){if(aB.lines.show){at(aB)}if(aB.bars.show){e(aB)}if(aB.points.show){ao(aB)}}function at(aE){function aD(aP,aQ,aI,aU,aT){var aV=aP.points,aJ=aP.pointsize,aN=null,aM=null;H.beginPath();for(var aO=aJ;aO<aV.length;aO+=aJ){var aL=aV[aO-aJ],aS=aV[aO-aJ+1],aK=aV[aO],aR=aV[aO+1];if(aL==null||aK==null){continue}if(aS<=aR&&aS<aT.min){if(aR<aT.min){continue}aL=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.min}else{if(aR<=aS&&aR<aT.min){if(aS<aT.min){continue}aK=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.min}}if(aS>=aR&&aS>aT.max){if(aR>aT.max){continue}aL=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.max}else{if(aR>=aS&&aR>aT.max){if(aS>aT.max){continue}aK=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.max}}if(aL<=aK&&aL<aU.min){if(aK<aU.min){continue}aS=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.min}else{if(aK<=aL&&aK<aU.min){if(aL<aU.min){continue}aR=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.min}}if(aL>=aK&&aL>aU.max){if(aK>aU.max){continue}aS=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.max}else{if(aK>=aL&&aK>aU.max){if(aL>aU.max){continue}aR=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.max}}if(aL!=aN||aS!=aM){H.moveTo(aU.p2c(aL)+aQ,aT.p2c(aS)+aI)}aN=aK;aM=aR;H.lineTo(aU.p2c(aK)+aQ,aT.p2c(aR)+aI)}H.stroke()}function aF(aI,aQ,aP){var aW=aI.points,aV=aI.pointsize,aN=Math.min(Math.max(0,aP.min),aP.max),aX=0,aU,aT=false,aM=1,aL=0,aR=0;while(true){if(aV>0&&aX>aW.length+aV){break}aX+=aV;var aZ=aW[aX-aV],aK=aW[aX-aV+aM],aY=aW[aX],aJ=aW[aX+aM];if(aT){if(aV>0&&aZ!=null&&aY==null){aR=aX;aV=-aV;aM=2;continue}if(aV<0&&aX==aL+aV){H.fill();aT=false;aV=-aV;aM=1;aX=aL=aR+aV;continue}}if(aZ==null||aY==null){continue}if(aZ<=aY&&aZ<aQ.min){if(aY<aQ.min){continue}aK=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.min}else{if(aY<=aZ&&aY<aQ.min){if(aZ<aQ.min){continue}aJ=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.min}}if(aZ>=aY&&aZ>aQ.max){if(aY>aQ.max){continue}aK=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.max}else{if(aY>=aZ&&aY>aQ.max){if(aZ>aQ.max){continue}aJ=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.max}}if(!aT){H.beginPath();H.moveTo(aQ.p2c(aZ),aP.p2c(aN));aT=true}if(aK>=aP.max&&aJ>=aP.max){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.max));H.lineTo(aQ.p2c(aY),aP.p2c(aP.max));continue}else{if(aK<=aP.min&&aJ<=aP.min){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.min));H.lineTo(aQ.p2c(aY),aP.p2c(aP.min));continue}}var aO=aZ,aS=aY;if(aK<=aJ&&aK<aP.min&&aJ>=aP.min){aZ=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.min}else{if(aJ<=aK&&aJ<aP.min&&aK>=aP.min){aY=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.min}}if(aK>=aJ&&aK>aP.max&&aJ<=aP.max){aZ=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.max}else{if(aJ>=aK&&aJ>aP.max&&aK<=aP.max){aY=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.max}}if(aZ!=aO){H.lineTo(aQ.p2c(aO),aP.p2c(aK))}H.lineTo(aQ.p2c(aZ),aP.p2c(aK));H.lineTo(aQ.p2c(aY),aP.p2c(aJ));if(aY!=aS){H.lineTo(aQ.p2c(aY),aP.p2c(aJ));H.lineTo(aQ.p2c(aS),aP.p2c(aJ))}}}H.save();H.translate(q.left,q.top);H.lineJoin=\"round\";var aG=aE.lines.lineWidth,aB=aE.shadowSize;if(aG>0&&aB>0){H.lineWidth=aB;H.strokeStyle=\"rgba(0,0,0,0.1)\";var aH=Math.PI/18;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/2),Math.cos(aH)*(aG/2+aB/2),aE.xaxis,aE.yaxis);H.lineWidth=aB/2;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/4),Math.cos(aH)*(aG/2+aB/4),aE.xaxis,aE.yaxis)}H.lineWidth=aG;H.strokeStyle=aE.color;var aC=ae(aE.lines,aE.color,0,w);if(aC){H.fillStyle=aC;aF(aE.datapoints,aE.xaxis,aE.yaxis)}if(aG>0){aD(aE.datapoints,0,0,aE.xaxis,aE.yaxis)}H.restore()}function ao(aE){function aH(aN,aM,aU,aK,aS,aT,aQ,aJ){var aR=aN.points,aI=aN.pointsize;for(var aL=0;aL<aR.length;aL+=aI){var aP=aR[aL],aO=aR[aL+1];if(aP==null||aP<aT.min||aP>aT.max||aO<aQ.min||aO>aQ.max){continue}H.beginPath();aP=aT.p2c(aP);aO=aQ.p2c(aO)+aK;if(aJ==\"circle\"){H.arc(aP,aO,aM,0,aS?Math.PI:Math.PI*2,false)}else{aJ(H,aP,aO,aM,aS)}H.closePath();if(aU){H.fillStyle=aU;H.fill()}H.stroke()}}H.save();H.translate(q.left,q.top);var aG=aE.points.lineWidth,aC=aE.shadowSize,aB=aE.points.radius,aF=aE.points.symbol;if(aG>0&&aC>0){var aD=aC/2;H.lineWidth=aD;H.strokeStyle=\"rgba(0,0,0,0.1)\";aH(aE.datapoints,aB,null,aD+aD/2,true,aE.xaxis,aE.yaxis,aF);H.strokeStyle=\"rgba(0,0,0,0.2)\";aH(aE.datapoints,aB,null,aD/2,true,aE.xaxis,aE.yaxis,aF)}H.lineWidth=aG;H.strokeStyle=aE.color;aH(aE.datapoints,aB,ae(aE.points,aE.color),0,false,aE.xaxis,aE.yaxis,aF);H.restore()}function E(aN,aM,aV,aI,aQ,aF,aD,aL,aK,aU,aR,aC){var aE,aT,aJ,aP,aG,aB,aO,aH,aS;if(aR){aH=aB=aO=true;aG=false;aE=aV;aT=aN;aP=aM+aI;aJ=aM+aQ;if(aT<aE){aS=aT;aT=aE;aE=aS;aG=true;aB=false}}else{aG=aB=aO=true;aH=false;aE=aN+aI;aT=aN+aQ;aJ=aV;aP=aM;if(aP<aJ){aS=aP;aP=aJ;aJ=aS;aH=true;aO=false}}if(aT<aL.min||aE>aL.max||aP<aK.min||aJ>aK.max){return}if(aE<aL.min){aE=aL.min;aG=false}if(aT>aL.max){aT=aL.max;aB=false}if(aJ<aK.min){aJ=aK.min;aH=false}if(aP>aK.max){aP=aK.max;aO=false}aE=aL.p2c(aE);aJ=aK.p2c(aJ);aT=aL.p2c(aT);aP=aK.p2c(aP);if(aD){aU.beginPath();aU.moveTo(aE,aJ);aU.lineTo(aE,aP);aU.lineTo(aT,aP);aU.lineTo(aT,aJ);aU.fillStyle=aD(aJ,aP);aU.fill()}if(aC>0&&(aG||aB||aO||aH)){aU.beginPath();aU.moveTo(aE,aJ+aF);if(aG){aU.lineTo(aE,aP+aF)}else{aU.moveTo(aE,aP+aF)}if(aO){aU.lineTo(aT,aP+aF)}else{aU.moveTo(aT,aP+aF)}if(aB){aU.lineTo(aT,aJ+aF)}else{aU.moveTo(aT,aJ+aF)}if(aH){aU.lineTo(aE,aJ+aF)}else{aU.moveTo(aE,aJ+aF)}aU.stroke()}}function e(aD){function aC(aJ,aI,aL,aG,aK,aN,aM){var aO=aJ.points,aF=aJ.pointsize;for(var aH=0;aH<aO.length;aH+=aF){if(aO[aH]==null){continue}E(aO[aH],aO[aH+1],aO[aH+2],aI,aL,aG,aK,aN,aM,H,aD.bars.horizontal,aD.bars.lineWidth)}}H.save();H.translate(q.left,q.top);H.lineWidth=aD.bars.lineWidth;H.strokeStyle=aD.color;var aB=aD.bars.align==\"left\"?0:-aD.bars.barWidth/2;var aE=aD.bars.fill?function(aF,aG){return ae(aD.bars,aD.color,aF,aG)}:null;aC(aD.datapoints,aB,aB+aD.bars.barWidth,0,aE,aD.xaxis,aD.yaxis);H.restore()}function ae(aD,aB,aC,aF){var aE=aD.fill;if(!aE){return null}if(aD.fillColor){return am(aD.fillColor,aC,aF,aB)}var aG=c.color.parse(aB);aG.a=typeof aE==\"number\"?aE:0.4;aG.normalize();return aG.toString()}function o(){av.find(\".legend\").remove();if(!O.legend.show){return}var aH=[],aF=false,aN=O.legend.labelFormatter,aM,aJ;for(var aE=0;aE<Q.length;++aE){aM=Q[aE];aJ=aM.label;if(!aJ){continue}if(aE%O.legend.noColumns==0){if(aF){aH.push(\"</tr>\")}aH.push(\"<tr>\");aF=true}if(aN){aJ=aN(aJ,aM)}aH.push('<td class=\"legendColorBox\"><div style=\"border:1px solid '+O.legend.labelBoxBorderColor+';padding:1px\"><div style=\"width:4px;height:0;border:5px solid '+aM.color+';overflow:hidden\"></div></div></td><td class=\"legendLabel\">'+aJ+\"</td>\")}if(aF){aH.push(\"</tr>\")}if(aH.length==0){return}var aL='<table style=\"font-size:smaller;color:'+O.grid.color+'\">'+aH.join(\"\")+\"</table>\";if(O.legend.container!=null){c(O.legend.container).html(aL)}else{var aI=\"\",aC=O.legend.position,aD=O.legend.margin;if(aD[0]==null){aD=[aD,aD]}if(aC.charAt(0)==\"n\"){aI+=\"top:\"+(aD[1]+q.top)+\"px;\"}else{if(aC.charAt(0)==\"s\"){aI+=\"bottom:\"+(aD[1]+q.bottom)+\"px;\"}}if(aC.charAt(1)==\"e\"){aI+=\"right:\"+(aD[0]+q.right)+\"px;\"}else{if(aC.charAt(1)==\"w\"){aI+=\"left:\"+(aD[0]+q.left)+\"px;\"}}var aK=c('<div class=\"legend\">'+aL.replace('style=\"','style=\"position:absolute;'+aI+\";\")+\"</div>\").appendTo(av);if(O.legend.backgroundOpacity!=0){var aG=O.legend.backgroundColor;if(aG==null){aG=O.grid.backgroundColor;if(aG&&typeof aG==\"string\"){aG=c.color.parse(aG)}else{aG=c.color.extract(aK,\"background-color\")}aG.a=1;aG=aG.toString()}var aB=aK.children();c('<div style=\"position:absolute;width:'+aB.width()+\"px;height:\"+aB.height()+\"px;\"+aI+\"background-color:\"+aG+';\"> </div>').prependTo(aK).css(\"opacity\",O.legend.backgroundOpacity)}}}var ab=[],M=null;function K(aI,aG,aD){var aO=O.grid.mouseActiveRadius,a0=aO*aO+1,aY=null,aR=false,aW,aU;for(aW=Q.length-1;aW>=0;--aW){if(!aD(Q[aW])){continue}var aP=Q[aW],aH=aP.xaxis,aF=aP.yaxis,aV=aP.datapoints.points,aT=aP.datapoints.pointsize,aQ=aH.c2p(aI),aN=aF.c2p(aG),aC=aO/aH.scale,aB=aO/aF.scale;if(aH.options.inverseTransform){aC=Number.MAX_VALUE}if(aF.options.inverseTransform){aB=Number.MAX_VALUE}if(aP.lines.show||aP.points.show){for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1];if(aK==null){continue}if(aK-aQ>aC||aK-aQ<-aC||aJ-aN>aB||aJ-aN<-aB){continue}var aM=Math.abs(aH.p2c(aK)-aI),aL=Math.abs(aF.p2c(aJ)-aG),aS=aM*aM+aL*aL;if(aS<a0){a0=aS;aY=[aW,aU/aT]}}}if(aP.bars.show&&!aY){var aE=aP.bars.align==\"left\"?0:-aP.bars.barWidth/2,aX=aE+aP.bars.barWidth;for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1],aZ=aV[aU+2];if(aK==null){continue}if(Q[aW].bars.horizontal?(aQ<=Math.max(aZ,aK)&&aQ>=Math.min(aZ,aK)&&aN>=aJ+aE&&aN<=aJ+aX):(aQ>=aK+aE&&aQ<=aK+aX&&aN>=Math.min(aZ,aJ)&&aN<=Math.max(aZ,aJ))){aY=[aW,aU/aT]}}}}if(aY){aW=aY[0];aU=aY[1];aT=Q[aW].datapoints.pointsize;return{datapoint:Q[aW].datapoints.points.slice(aU*aT,(aU+1)*aT),dataIndex:aU,series:Q[aW],seriesIndex:aW}}return null}function aa(aB){if(O.grid.hoverable){u(\"plothover\",aB,function(aC){return aC.hoverable!=false})}}function l(aB){if(O.grid.hoverable){u(\"plothover\",aB,function(aC){return false})}}function R(aB){u(\"plotclick\",aB,function(aC){return aC.clickable!=false})}function u(aC,aB,aD){var aE=y.offset(),aH=aB.pageX-aE.left-q.left,aF=aB.pageY-aE.top-q.top,aJ=C({left:aH,top:aF});aJ.pageX=aB.pageX;aJ.pageY=aB.pageY;var aK=K(aH,aF,aD);if(aK){aK.pageX=parseInt(aK.series.xaxis.p2c(aK.datapoint[0])+aE.left+q.left);aK.pageY=parseInt(aK.series.yaxis.p2c(aK.datapoint[1])+aE.top+q.top)}if(O.grid.autoHighlight){for(var aG=0;aG<ab.length;++aG){var aI=ab[aG];if(aI.auto==aC&&!(aK&&aI.series==aK.series&&aI.point[0]==aK.datapoint[0]&&aI.point[1]==aK.datapoint[1])){T(aI.series,aI.point)}}if(aK){x(aK.series,aK.datapoint,aC)}}av.trigger(aC,[aJ,aK])}function f(){if(!M){M=setTimeout(s,30)}}function s(){M=null;A.save();A.clearRect(0,0,G,I);A.translate(q.left,q.top);var aC,aB;for(aC=0;aC<ab.length;++aC){aB=ab[aC];if(aB.series.bars.show){v(aB.series,aB.point)}else{ay(aB.series,aB.point)}}A.restore();an(ak.drawOverlay,[A])}function x(aD,aB,aF){if(typeof aD==\"number\"){aD=Q[aD]}if(typeof aB==\"number\"){var aE=aD.datapoints.pointsize;aB=aD.datapoints.points.slice(aE*aB,aE*(aB+1))}var aC=al(aD,aB);if(aC==-1){ab.push({series:aD,point:aB,auto:aF});f()}else{if(!aF){ab[aC].auto=false}}}function T(aD,aB){if(aD==null&&aB==null){ab=[];f()}if(typeof aD==\"number\"){aD=Q[aD]}if(typeof aB==\"number\"){aB=aD.data[aB]}var aC=al(aD,aB);if(aC!=-1){ab.splice(aC,1);f()}}function al(aD,aE){for(var aB=0;aB<ab.length;++aB){var aC=ab[aB];if(aC.series==aD&&aC.point[0]==aE[0]&&aC.point[1]==aE[1]){return aB}}return -1}function ay(aE,aD){var aC=aD[0],aI=aD[1],aH=aE.xaxis,aG=aE.yaxis;if(aC<aH.min||aC>aH.max||aI<aG.min||aI>aG.max){return}var aF=aE.points.radius+aE.points.lineWidth/2;A.lineWidth=aF;A.strokeStyle=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aB=1.5*aF,aC=aH.p2c(aC),aI=aG.p2c(aI);A.beginPath();if(aE.points.symbol==\"circle\"){A.arc(aC,aI,aB,0,2*Math.PI,false)}else{aE.points.symbol(A,aC,aI,aB,false)}A.closePath();A.stroke()}function v(aE,aB){A.lineWidth=aE.bars.lineWidth;A.strokeStyle=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aD=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aC=aE.bars.align==\"left\"?0:-aE.bars.barWidth/2;E(aB[0],aB[1],aB[2]||0,aC,aC+aE.bars.barWidth,0,function(){return aD},aE.xaxis,aE.yaxis,A,aE.bars.horizontal,aE.bars.lineWidth)}function am(aJ,aB,aH,aC){if(typeof aJ==\"string\"){return aJ}else{var aI=H.createLinearGradient(0,aH,0,aB);for(var aE=0,aD=aJ.colors.length;aE<aD;++aE){var aF=aJ.colors[aE];if(typeof aF!=\"string\"){var aG=c.color.parse(aC);if(aF.brightness!=null){aG=aG.scale(\"rgb\",aF.brightness)}if(aF.opacity!=null){aG.a*=aF.opacity}aF=aG.toString()}aI.addColorStop(aE/(aD-1),aF)}return aI}}}c.plot=function(g,e,d){var f=new b(c(g),e,d,c.plot.plugins);return f};c.plot.version=\"0.7\";c.plot.plugins=[];c.plot.formatDate=function(l,f,h){var o=function(d){d=\"\"+d;return d.length==1?\"0\"+d:d};var e=[];var p=false,j=false;var n=l.getUTCHours();var k=n<12;if(h==null){h=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"]}if(f.search(/%p|%P/)!=-1){if(n>12){n=n-12}else{if(n==0){n=12}}}for(var g=0;g<f.length;++g){var m=f.charAt(g);if(p){switch(m){case\"h\":m=\"\"+n;break;case\"H\":m=o(n);break;case\"M\":m=o(l.getUTCMinutes());break;case\"S\":m=o(l.getUTCSeconds());break;case\"d\":m=\"\"+l.getUTCDate();break;case\"m\":m=\"\"+(l.getUTCMonth()+1);break;case\"y\":m=\"\"+l.getUTCFullYear();break;case\"b\":m=\"\"+h[l.getUTCMonth()];break;case\"p\":m=(k)?(\"am\"):(\"pm\");break;case\"P\":m=(k)?(\"AM\"):(\"PM\");break;case\"0\":m=\"\";j=true;break}if(m&&j){m=o(m);j=false}e.push(m);if(!j){p=false}}else{if(m==\"%\"){p=true}else{e.push(m)}}}return e.join(\"\")};function a(e,d){return d*Math.floor(e/d)}})(jQuery);", | |
"", | |
"(function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger(\"plotselecting\",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one(\"mouseup\",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger(\"plotunselected\",[]);k.getPlaceholder().trigger(\"plotselecting\",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger(\"plotselected\",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger(\"selected\",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode==\"y\"){w.x=w==p.first?0:k.width()}if(v.selection.mode==\"x\"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger(\"plotunselected\",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+\"axis\";if(!s[A]&&t.n==1){A=w+\"axis\"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w==\"x\"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+\"1\"];z=s[w+\"2\"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode==\"y\"){p.first.x=0;p.second.x=k.width()}else{u=c(t,\"x\");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode==\"x\"){p.first.y=0;p.second.y=k.height()}else{u=c(t,\"y\");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale(\"a\",0.8).toString();D.lineWidth=1;D.lineJoin=\"round\";D.fillStyle=z.scale(\"a\",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind(\"mousemove\",e);s.unbind(\"mousedown\",n);if(r){a(document).unbind(\"mouseup\",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:\"#e8cfac\"}},name:\"selection\",version:\"1.1\"})})(jQuery);", | |
"'''" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 22 | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"This is the code that plugs into ipython to allow inline plotting in a notebook" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"#-----------------------------------------------------------------------------", | |
"# Imports", | |
"#-----------------------------------------------------------------------------", | |
"from __future__ import print_function", | |
"", | |
"# Stdlib imports", | |
"import string", | |
"import json", | |
"", | |
"# Third-party imports", | |
"", | |
"# Our own imports", | |
"import IPython.core.display", | |
"", | |
"", | |
"IPython.core.display.display_javascript(IPython.core.display.Javascript(data=flot))", | |
"#-----------------------------------------------------------------------------", | |
"# Classes and functions", | |
"#-----------------------------------------------------------------------------", | |
"", | |
"class Plot():", | |
" '''", | |
" This class contains methods for using the javascript plotting backend flot", | |
" to plot in an ipython notebook. the number of pixels can be set using the", | |
" pixelsx and pixelsy atttributes and the legend location can be set using ", | |
" the legendloc attribute.", | |
" possible legendloc values : 'ne', 'nw', 'se', 'sw'", | |
" '''", | |
" nplots = 0", | |
" pixelsx = 600", | |
" pixelsy = 300", | |
" legendloc = \"ne\"", | |
"", | |
" def _read_data(self, data, data1, label):", | |
" #This function takes the python data and encodes it into JSON data", | |
" d = \"\"", | |
" labelstring = \"\"", | |
" encoder = json.JSONEncoder()", | |
" if data is not None:", | |
" if type(data[0]) == list or ('numpy' in str(type(data[0])) and data[0].shape != () ): ", | |
" for index,item in enumerate(data):", | |
" if data1 is not None:", | |
" d += \"var d\"+str(index)+\" =\"+ encoder.encode(zip(item,data1[index])) +\";\\n\" ", | |
" if label is not None and type(label) == list:", | |
" labelstring += \"{ label:\\\"\" +label[index] + \"\\\", data:d\" + str(index) + \" },\"", | |
" else:", | |
" labelstring += \"{ data:d\" + str(index) + \" },\"", | |
" else:", | |
" d += \"var d\"+str(index)+\" =\"+ encoder.encode(zip(item,range(len(item)))) +\";\\n\" ", | |
" if label is not None and type(label) == list:", | |
" labelstring += \"{ label:\\\"\" +label[index] + \"\\\", data:d\" + str(index) + \" },\"", | |
" else:", | |
" labelstring += \"{ data:d\" + str(index) + \" },\"", | |
" labelstring = string.rstrip(labelstring,\",\")", | |
" else:", | |
" datastring = \"var d1 = \"", | |
" if data1 is not None:", | |
" datastring += encoder.encode(zip(data,data1)) +\";\"", | |
" else:", | |
" datastring += encoder.encode(zip(data,range(len(data)))) +\";\"", | |
" ", | |
" if label is not None and type(label) == str:", | |
" labelstring = \"{ label : \\\"\" + label + \"\\\",\" + \"data:d1}\"", | |
" else:", | |
" labelstring = \"{data:d1}\"", | |
" d = datastring", | |
"", | |
" return d, labelstring", | |
" ", | |
" def plot_figure( self, data = None, data1 = None, label = None):", | |
" '''", | |
" This method plots the inputs data and data1 based on the following", | |
" rules. If only data exists each array in that input field will be", | |
" plotted with the x-axis having integer values. If data exists", | |
" in both data and data1 it will be assumed to be of the format:", | |
" [x0,x1,x2...]", | |
" [y0,y1,y2...]", | |
" where xn and yn are either numerical values of arrays of values.", | |
" the label is assumed to be a string if there is only one input set", | |
" or an array of strings equal in length to the number of arrays in", | |
" data.", | |
" '''", | |
" if data is not None and len(data) > 0: ", | |
" d, label = self._read_data(data,data1,label)", | |
" nplotstxt = str(self.nplots) ", | |
" src = d + \"\"\"", | |
" var options = {", | |
" selection: { mode: \"xy\" },", | |
" legend: { position:\\\"\"\"\" + self.legendloc + \"\"\"\\\"},", | |
" };", | |
" ", | |
" var plot\"\"\" + nplotstxt + \"\"\" = $.plot($(\"#placeholder\"\"\" + nplotstxt + \"\"\"\"), [ \"\"\" + label + \"\"\"],options);", | |
" var minx\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().xaxis.min;", | |
" var maxx\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().xaxis.max;", | |
" var miny\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().yaxis.min;", | |
" var maxy\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().yaxis.max;", | |
" ", | |
" var iminx\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().xaxis.min;", | |
" var imaxx\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().xaxis.max;", | |
" var iminy\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().yaxis.min;", | |
" var imaxy\"\"\" + nplotstxt + \"\"\" = plot\"\"\" + nplotstxt + \"\"\".getAxes().yaxis.max; ", | |
" ", | |
" $(\"#placeholder\"\"\" + nplotstxt + \"\"\"\").bind(\"plotselected\", function (event, ranges) {", | |
" minx\"\"\" + nplotstxt + \"\"\" = ranges.xaxis.from;", | |
" maxx\"\"\" + nplotstxt + \"\"\" = ranges.xaxis.to;", | |
" miny\"\"\" + nplotstxt + \"\"\" = ranges.yaxis.from;", | |
" maxy\"\"\" + nplotstxt + \"\"\" = ranges.yaxis.to;", | |
" });", | |
" ", | |
"", | |
" $(\"#zoom\"\"\" + nplotstxt + \"\"\"\").click(function() {", | |
" $.plot($(\"#placeholder\"\"\" + nplotstxt + \"\"\"\"), plot\"\"\" + nplotstxt + \"\"\".getData(),", | |
" $.extend(true, {}, options, {", | |
" xaxis: { min: minx\"\"\" + nplotstxt + \"\"\" , max: maxx\"\"\" + nplotstxt + \"\"\" },", | |
" yaxis: { min: miny\"\"\" + nplotstxt + \"\"\" , max: maxy\"\"\" + nplotstxt + \"\"\" }", | |
" }));", | |
"", | |
" });", | |
" ", | |
" $(\"#home\"\"\" + nplotstxt + \"\"\"\").click(function() {", | |
" $.plot($(\"#placeholder\"\"\" + nplotstxt + \"\"\"\"), plot\"\"\" + nplotstxt + \"\"\".getData(),", | |
" $.extend(true, {}, options, {", | |
" xaxis: { min: iminx\"\"\" + nplotstxt + \"\"\" , max: imaxx\"\"\" + nplotstxt + \"\"\" },", | |
" yaxis: { min: iminy\"\"\" + nplotstxt + \"\"\" , max: imaxy\"\"\" + nplotstxt + \"\"\" }", | |
" }));", | |
"", | |
" });", | |
" \"\"\"", | |
" else:", | |
" print(\"No data given to plot\")", | |
" return", | |
" self._insert_placeholder()", | |
" self.nplots = self.nplots + 1", | |
" IPython.core.display.display_javascript(IPython.core.display.Javascript(data=src))", | |
" #,lib=[\"http://crbates.github.com/flot/jquery.flot.min.js\",\"http://crbates.github.com/flot/jquery.flot.navigate.min.js\",\"http://crbates.github.com/flot/jquery.flot.selection.min.js\"]))", | |
"", | |
" def _insert_placeholder(self):", | |
" #This function inserts the html tag for the plot", | |
" nplotstxt = str(self.nplots)", | |
" src = \"\"\"", | |
" <div id=\"placeholder\"\"\" + nplotstxt + \"\"\"\"\" style=\"width:", | |
" \"\"\" + str(self.pixelsx) + \"\"\"px;height:\"\"\" + str(self.pixelsy) + \"\"\"px;\"></div>", | |
" <input id=\"home\"\"\" + nplotstxt + \"\"\"\" type=\"button\" value=\"home\"> <input id=\"zoom\"\"\" + nplotstxt + \"\"\"\" type=\"button\" value=\"zoom to selection\">", | |
" \"\"\"", | |
" IPython.core.display.display_html(IPython.core.display.HTML(data=src))", | |
"" | |
], | |
"language": "python", | |
"outputs": [ | |
{ | |
"javascript": [ | |
"", | |
"/* Javascript plotting library for jQuery, v. 0.7.", | |
" *", | |
" * Released under the MIT license by IOLA, December 2007.", | |
" *", | |
" */", | |
"(function(b){b.color={};b.color.make=function(d,e,g,f){var c={};c.r=d||0;c.g=e||0;c.b=g||0;c.a=f!=null?f:1;c.add=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]+=j}return c.normalize()};c.scale=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]*=j}return c.normalize()};c.toString=function(){if(c.a>=1){return\"rgb(\"+[c.r,c.g,c.b].join(\",\")+\")\"}else{return\"rgba(\"+[c.r,c.g,c.b,c.a].join(\",\")+\")\"}};c.normalize=function(){function h(k,j,l){return j<k?k:(j>l?l:j)}c.r=h(0,parseInt(c.r),255);c.g=h(0,parseInt(c.g),255);c.b=h(0,parseInt(c.b),255);c.a=h(0,c.a,1);return c};c.clone=function(){return b.color.make(c.r,c.b,c.g,c.a)};return c.normalize()};b.color.extract=function(d,e){var c;do{c=d.css(e).toLowerCase();if(c!=\"\"&&c!=\"transparent\"){break}d=d.parent()}while(!b.nodeName(d.get(0),\"body\"));if(c==\"rgba(0, 0, 0, 0)\"){c=\"transparent\"}return b.color.parse(c)};b.color.parse=function(c){var d,f=b.color.make;if(d=/rgb\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10))}if(d=/rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10),parseFloat(d[4]))}if(d=/rgb\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55)}if(d=/rgba\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55,parseFloat(d[4]))}if(d=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c)){return f(parseInt(d[1],16),parseInt(d[2],16),parseInt(d[3],16))}if(d=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c)){return f(parseInt(d[1]+d[1],16),parseInt(d[2]+d[2],16),parseInt(d[3]+d[3],16))}var e=b.trim(c).toLowerCase();if(e==\"transparent\"){return f(255,255,255,0)}else{d=a[e]||[0,0,0];return f(d[0],d[1],d[2])}};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function(c){function b(av,ai,J,af){var Q=[],O={colors:[\"#edc240\",\"#afd8f8\",\"#cb4b4b\",\"#4da74d\",\"#9440ed\"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:\"#ccc\",container:null,position:\"ne\",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{show:null,position:\"bottom\",mode:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:false},yaxis:{autoscaleMargin:0.02,position:\"left\"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:\"#ffffff\",symbol:\"circle\"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:\"left\",horizontal:false},shadowSize:3},grid:{show:true,aboveData:false,color:\"#545454\",backgroundColor:null,borderColor:null,tickColor:null,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:\"#f4f4f4\",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},hooks:{}},az=null,ad=null,y=null,H=null,A=null,p=[],aw=[],q={left:0,right:0,top:0,bottom:0},G=0,I=0,h=0,w=0,ak={processOptions:[],processRawData:[],processDatapoints:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},aq=this;aq.setData=aj;aq.setupGrid=t;aq.draw=W;aq.getPlaceholder=function(){return av};aq.getCanvas=function(){return az};aq.getPlotOffset=function(){return q};aq.width=function(){return h};aq.height=function(){return w};aq.offset=function(){var aB=y.offset();aB.left+=q.left;aB.top+=q.top;return aB};aq.getData=function(){return Q};aq.getAxes=function(){var aC={},aB;c.each(p.concat(aw),function(aD,aE){if(aE){aC[aE.direction+(aE.n!=1?aE.n:\"\")+\"axis\"]=aE}});return aC};aq.getXAxes=function(){return p};aq.getYAxes=function(){return aw};aq.c2p=C;aq.p2c=ar;aq.getOptions=function(){return O};aq.highlight=x;aq.unhighlight=T;aq.triggerRedrawOverlay=f;aq.pointOffset=function(aB){return{left:parseInt(p[aA(aB,\"x\")-1].p2c(+aB.x)+q.left),top:parseInt(aw[aA(aB,\"y\")-1].p2c(+aB.y)+q.top)}};aq.shutdown=ag;aq.resize=function(){B();g(az);g(ad)};aq.hooks=ak;F(aq);Z(J);X();aj(ai);t();W();ah();function an(aD,aB){aB=[aq].concat(aB);for(var aC=0;aC<aD.length;++aC){aD[aC].apply(this,aB)}}function F(){for(var aB=0;aB<af.length;++aB){var aC=af[aB];aC.init(aq);if(aC.options){c.extend(true,O,aC.options)}}}function Z(aC){var aB;c.extend(true,O,aC);if(O.xaxis.color==null){O.xaxis.color=O.grid.color}if(O.yaxis.color==null){O.yaxis.color=O.grid.color}if(O.xaxis.tickColor==null){O.xaxis.tickColor=O.grid.tickColor}if(O.yaxis.tickColor==null){O.yaxis.tickColor=O.grid.tickColor}if(O.grid.borderColor==null){O.grid.borderColor=O.grid.color}if(O.grid.tickColor==null){O.grid.tickColor=c.color.parse(O.grid.color).scale(\"a\",0.22).toString()}for(aB=0;aB<Math.max(1,O.xaxes.length);++aB){O.xaxes[aB]=c.extend(true,{},O.xaxis,O.xaxes[aB])}for(aB=0;aB<Math.max(1,O.yaxes.length);++aB){O.yaxes[aB]=c.extend(true,{},O.yaxis,O.yaxes[aB])}if(O.xaxis.noTicks&&O.xaxis.ticks==null){O.xaxis.ticks=O.xaxis.noTicks}if(O.yaxis.noTicks&&O.yaxis.ticks==null){O.yaxis.ticks=O.yaxis.noTicks}if(O.x2axis){O.xaxes[1]=c.extend(true,{},O.xaxis,O.x2axis);O.xaxes[1].position=\"top\"}if(O.y2axis){O.yaxes[1]=c.extend(true,{},O.yaxis,O.y2axis);O.yaxes[1].position=\"right\"}if(O.grid.coloredAreas){O.grid.markings=O.grid.coloredAreas}if(O.grid.coloredAreasColor){O.grid.markingsColor=O.grid.coloredAreasColor}if(O.lines){c.extend(true,O.series.lines,O.lines)}if(O.points){c.extend(true,O.series.points,O.points)}if(O.bars){c.extend(true,O.series.bars,O.bars)}if(O.shadowSize!=null){O.series.shadowSize=O.shadowSize}for(aB=0;aB<O.xaxes.length;++aB){V(p,aB+1).options=O.xaxes[aB]}for(aB=0;aB<O.yaxes.length;++aB){V(aw,aB+1).options=O.yaxes[aB]}for(var aD in ak){if(O.hooks[aD]&&O.hooks[aD].length){ak[aD]=ak[aD].concat(O.hooks[aD])}}an(ak.processOptions,[O])}function aj(aB){Q=Y(aB);ax();z()}function Y(aE){var aC=[];for(var aB=0;aB<aE.length;++aB){var aD=c.extend(true,{},O.series);if(aE[aB].data!=null){aD.data=aE[aB].data;delete aE[aB].data;c.extend(true,aD,aE[aB]);aE[aB].data=aD.data}else{aD.data=aE[aB]}aC.push(aD)}return aC}function aA(aC,aD){var aB=aC[aD+\"axis\"];if(typeof aB==\"object\"){aB=aB.n}if(typeof aB!=\"number\"){aB=1}return aB}function m(){return c.grep(p.concat(aw),function(aB){return aB})}function C(aE){var aC={},aB,aD;for(aB=0;aB<p.length;++aB){aD=p[aB];if(aD&&aD.used){aC[\"x\"+aD.n]=aD.c2p(aE.left)}}for(aB=0;aB<aw.length;++aB){aD=aw[aB];if(aD&&aD.used){aC[\"y\"+aD.n]=aD.c2p(aE.top)}}if(aC.x1!==undefined){aC.x=aC.x1}if(aC.y1!==undefined){aC.y=aC.y1}return aC}function ar(aF){var aD={},aC,aE,aB;for(aC=0;aC<p.length;++aC){aE=p[aC];if(aE&&aE.used){aB=\"x\"+aE.n;if(aF[aB]==null&&aE.n==1){aB=\"x\"}if(aF[aB]!=null){aD.left=aE.p2c(aF[aB]);break}}}for(aC=0;aC<aw.length;++aC){aE=aw[aC];if(aE&&aE.used){aB=\"y\"+aE.n;if(aF[aB]==null&&aE.n==1){aB=\"y\"}if(aF[aB]!=null){aD.top=aE.p2c(aF[aB]);break}}}return aD}function V(aC,aB){if(!aC[aB-1]){aC[aB-1]={n:aB,direction:aC==p?\"x\":\"y\",options:c.extend(true,{},aC==p?O.xaxis:O.yaxis)}}return aC[aB-1]}function ax(){var aG;var aM=Q.length,aB=[],aE=[];for(aG=0;aG<Q.length;++aG){var aJ=Q[aG].color;if(aJ!=null){--aM;if(typeof aJ==\"number\"){aE.push(aJ)}else{aB.push(c.color.parse(Q[aG].color))}}}for(aG=0;aG<aE.length;++aG){aM=Math.max(aM,aE[aG]+1)}var aC=[],aF=0;aG=0;while(aC.length<aM){var aI;if(O.colors.length==aG){aI=c.color.make(100,100,100)}else{aI=c.color.parse(O.colors[aG])}var aD=aF%2==1?-1:1;aI.scale(\"rgb\",1+aD*Math.ceil(aF/2)*0.2);aC.push(aI);++aG;if(aG>=O.colors.length){aG=0;++aF}}var aH=0,aN;for(aG=0;aG<Q.length;++aG){aN=Q[aG];if(aN.color==null){aN.color=aC[aH].toString();++aH}else{if(typeof aN.color==\"number\"){aN.color=aC[aN.color].toString()}}if(aN.lines.show==null){var aL,aK=true;for(aL in aN){if(aN[aL]&&aN[aL].show){aK=false;break}}if(aK){aN.lines.show=true}}aN.xaxis=V(p,aA(aN,\"x\"));aN.yaxis=V(aw,aA(aN,\"y\"))}}function z(){var aO=Number.POSITIVE_INFINITY,aI=Number.NEGATIVE_INFINITY,aB=Number.MAX_VALUE,aU,aS,aR,aN,aD,aJ,aT,aP,aH,aG,aC,a0,aX,aL;function aF(a3,a2,a1){if(a2<a3.datamin&&a2!=-aB){a3.datamin=a2}if(a1>a3.datamax&&a1!=aB){a3.datamax=a1}}c.each(m(),function(a1,a2){a2.datamin=aO;a2.datamax=aI;a2.used=false});for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aJ.datapoints={points:[]};an(ak.processRawData,[aJ,aJ.data,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];var aZ=aJ.data,aW=aJ.datapoints.format;if(!aW){aW=[];aW.push({x:true,number:true,required:true});aW.push({y:true,number:true,required:true});if(aJ.bars.show||(aJ.lines.show&&aJ.lines.fill)){aW.push({y:true,number:true,required:false,defaultValue:0});if(aJ.bars.horizontal){delete aW[aW.length-1].y;aW[aW.length-1].x=true}}aJ.datapoints.format=aW}if(aJ.datapoints.pointsize!=null){continue}aJ.datapoints.pointsize=aW.length;aP=aJ.datapoints.pointsize;aT=aJ.datapoints.points;insertSteps=aJ.lines.show&&aJ.lines.steps;aJ.xaxis.used=aJ.yaxis.used=true;for(aS=aR=0;aS<aZ.length;++aS,aR+=aP){aL=aZ[aS];var aE=aL==null;if(!aE){for(aN=0;aN<aP;++aN){a0=aL[aN];aX=aW[aN];if(aX){if(aX.number&&a0!=null){a0=+a0;if(isNaN(a0)){a0=null}else{if(a0==Infinity){a0=aB}else{if(a0==-Infinity){a0=-aB}}}}if(a0==null){if(aX.required){aE=true}if(aX.defaultValue!=null){a0=aX.defaultValue}}}aT[aR+aN]=a0}}if(aE){for(aN=0;aN<aP;++aN){a0=aT[aR+aN];if(a0!=null){aX=aW[aN];if(aX.x){aF(aJ.xaxis,a0,a0)}if(aX.y){aF(aJ.yaxis,a0,a0)}}aT[aR+aN]=null}}else{if(insertSteps&&aR>0&&aT[aR-aP]!=null&&aT[aR-aP]!=aT[aR]&&aT[aR-aP+1]!=aT[aR+1]){for(aN=0;aN<aP;++aN){aT[aR+aP+aN]=aT[aR+aN]}aT[aR+1]=aT[aR-aP+1];aR+=aP}}}}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];an(ak.processDatapoints,[aJ,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aT=aJ.datapoints.points,aP=aJ.datapoints.pointsize;var aK=aO,aQ=aO,aM=aI,aV=aI;for(aS=0;aS<aT.length;aS+=aP){if(aT[aS]==null){continue}for(aN=0;aN<aP;++aN){a0=aT[aS+aN];aX=aW[aN];if(!aX||a0==aB||a0==-aB){continue}if(aX.x){if(a0<aK){aK=a0}if(a0>aM){aM=a0}}if(aX.y){if(a0<aQ){aQ=a0}if(a0>aV){aV=a0}}}}if(aJ.bars.show){var aY=aJ.bars.align==\"left\"?0:-aJ.bars.barWidth/2;if(aJ.bars.horizontal){aQ+=aY;aV+=aY+aJ.bars.barWidth}else{aK+=aY;aM+=aY+aJ.bars.barWidth}}aF(aJ.xaxis,aK,aM);aF(aJ.yaxis,aQ,aV)}c.each(m(),function(a1,a2){if(a2.datamin==aO){a2.datamin=null}if(a2.datamax==aI){a2.datamax=null}})}function j(aB,aC){var aD=document.createElement(\"canvas\");aD.className=aC;aD.width=G;aD.height=I;if(!aB){c(aD).css({position:\"absolute\",left:0,top:0})}c(aD).appendTo(av);if(!aD.getContext){aD=window.G_vmlCanvasManager.initElement(aD)}aD.getContext(\"2d\").save();return aD}function B(){G=av.width();I=av.height();if(G<=0||I<=0){throw\"Invalid dimensions for plot, width = \"+G+\", height = \"+I}}function g(aC){if(aC.width!=G){aC.width=G}if(aC.height!=I){aC.height=I}var aB=aC.getContext(\"2d\");aB.restore();aB.save()}function X(){var aC,aB=av.children(\"canvas.base\"),aD=av.children(\"canvas.overlay\");if(aB.length==0||aD==0){av.html(\"\");av.css({padding:0});if(av.css(\"position\")==\"static\"){av.css(\"position\",\"relative\")}B();az=j(true,\"base\");ad=j(false,\"overlay\");aC=false}else{az=aB.get(0);ad=aD.get(0);aC=true}H=az.getContext(\"2d\");A=ad.getContext(\"2d\");y=c([ad,az]);if(aC){av.data(\"plot\").shutdown();aq.resize();A.clearRect(0,0,G,I);y.unbind();av.children().not([az,ad]).remove()}av.data(\"plot\",aq)}function ah(){if(O.grid.hoverable){y.mousemove(aa);y.mouseleave(l)}if(O.grid.clickable){y.click(R)}an(ak.bindEvents,[y])}function ag(){if(M){clearTimeout(M)}y.unbind(\"mousemove\",aa);y.unbind(\"mouseleave\",l);y.unbind(\"click\",R);an(ak.shutdown,[y])}function r(aG){function aC(aH){return aH}var aF,aB,aD=aG.options.transform||aC,aE=aG.options.inverseTransform;if(aG.direction==\"x\"){aF=aG.scale=h/Math.abs(aD(aG.max)-aD(aG.min));aB=Math.min(aD(aG.max),aD(aG.min))}else{aF=aG.scale=w/Math.abs(aD(aG.max)-aD(aG.min));aF=-aF;aB=Math.max(aD(aG.max),aD(aG.min))}if(aD==aC){aG.p2c=function(aH){return(aH-aB)*aF}}else{aG.p2c=function(aH){return(aD(aH)-aB)*aF}}if(!aE){aG.c2p=function(aH){return aB+aH/aF}}else{aG.c2p=function(aH){return aE(aB+aH/aF)}}}function L(aD){var aB=aD.options,aF,aJ=aD.ticks||[],aI=[],aE,aK=aB.labelWidth,aG=aB.labelHeight,aC;function aH(aM,aL){return c('<div style=\"position:absolute;top:-10000px;'+aL+'font-size:smaller\"><div class=\"'+aD.direction+\"Axis \"+aD.direction+aD.n+'Axis\">'+aM.join(\"\")+\"</div></div>\").appendTo(av)}if(aD.direction==\"x\"){if(aK==null){aK=Math.floor(G/(aJ.length>0?aJ.length:1))}if(aG==null){aI=[];for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class=\"tickLabel\" style=\"float:left;width:'+aK+'px\">'+aE+\"</div>\")}}if(aI.length>0){aI.push('<div style=\"clear:left\"></div>');aC=aH(aI,\"width:10000px;\");aG=aC.height();aC.remove()}}}else{if(aK==null||aG==null){for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class=\"tickLabel\">'+aE+\"</div>\")}}if(aI.length>0){aC=aH(aI,\"\");if(aK==null){aK=aC.children().width()}if(aG==null){aG=aC.find(\"div.tickLabel\").height()}aC.remove()}}}if(aK==null){aK=0}if(aG==null){aG=0}aD.labelWidth=aK;aD.labelHeight=aG}function au(aD){var aC=aD.labelWidth,aL=aD.labelHeight,aH=aD.options.position,aF=aD.options.tickLength,aG=O.grid.axisMargin,aJ=O.grid.labelMargin,aK=aD.direction==\"x\"?p:aw,aE;var aB=c.grep(aK,function(aN){return aN&&aN.options.position==aH&&aN.reserveSpace});if(c.inArray(aD,aB)==aB.length-1){aG=0}if(aF==null){aF=\"full\"}var aI=c.grep(aK,function(aN){return aN&&aN.reserveSpace});var aM=c.inArray(aD,aI)==0;if(!aM&&aF==\"full\"){aF=5}if(!isNaN(+aF)){aJ+=+aF}if(aD.direction==\"x\"){aL+=aJ;if(aH==\"bottom\"){q.bottom+=aL+aG;aD.box={top:I-q.bottom,height:aL}}else{aD.box={top:q.top+aG,height:aL};q.top+=aL+aG}}else{aC+=aJ;if(aH==\"left\"){aD.box={left:q.left+aG,width:aC};q.left+=aC+aG}else{q.right+=aC+aG;aD.box={left:G-q.right,width:aC}}}aD.position=aH;aD.tickLength=aF;aD.box.padding=aJ;aD.innermost=aM}function U(aB){if(aB.direction==\"x\"){aB.box.left=q.left;aB.box.width=h}else{aB.box.top=q.top;aB.box.height=w}}function t(){var aC,aE=m();c.each(aE,function(aF,aG){aG.show=aG.options.show;if(aG.show==null){aG.show=aG.used}aG.reserveSpace=aG.show||aG.options.reserveSpace;n(aG)});allocatedAxes=c.grep(aE,function(aF){return aF.reserveSpace});q.left=q.right=q.top=q.bottom=0;if(O.grid.show){c.each(allocatedAxes,function(aF,aG){S(aG);P(aG);ap(aG,aG.ticks);L(aG)});for(aC=allocatedAxes.length-1;aC>=0;--aC){au(allocatedAxes[aC])}var aD=O.grid.minBorderMargin;if(aD==null){aD=0;for(aC=0;aC<Q.length;++aC){aD=Math.max(aD,Q[aC].points.radius+Q[aC].points.lineWidth/2)}}for(var aB in q){q[aB]+=O.grid.borderWidth;q[aB]=Math.max(aD,q[aB])}}h=G-q.left-q.right;w=I-q.bottom-q.top;c.each(aE,function(aF,aG){r(aG)});if(O.grid.show){c.each(allocatedAxes,function(aF,aG){U(aG)});k()}o()}function n(aE){var aF=aE.options,aD=+(aF.min!=null?aF.min:aE.datamin),aB=+(aF.max!=null?aF.max:aE.datamax),aH=aB-aD;if(aH==0){var aC=aB==0?1:0.01;if(aF.min==null){aD-=aC}if(aF.max==null||aF.min!=null){aB+=aC}}else{var aG=aF.autoscaleMargin;if(aG!=null){if(aF.min==null){aD-=aH*aG;if(aD<0&&aE.datamin!=null&&aE.datamin>=0){aD=0}}if(aF.max==null){aB+=aH*aG;if(aB>0&&aE.datamax!=null&&aE.datamax<=0){aB=0}}}}aE.min=aD;aE.max=aB}function S(aG){var aM=aG.options;var aH;if(typeof aM.ticks==\"number\"&&aM.ticks>0){aH=aM.ticks}else{aH=0.3*Math.sqrt(aG.direction==\"x\"?G:I)}var aT=(aG.max-aG.min)/aH,aO,aB,aN,aR,aS,aQ,aI;if(aM.mode==\"time\"){var aJ={second:1000,minute:60*1000,hour:60*60*1000,day:24*60*60*1000,month:30*24*60*60*1000,year:365.2425*24*60*60*1000};var aK=[[1,\"second\"],[2,\"second\"],[5,\"second\"],[10,\"second\"],[30,\"second\"],[1,\"minute\"],[2,\"minute\"],[5,\"minute\"],[10,\"minute\"],[30,\"minute\"],[1,\"hour\"],[2,\"hour\"],[4,\"hour\"],[8,\"hour\"],[12,\"hour\"],[1,\"day\"],[2,\"day\"],[3,\"day\"],[0.25,\"month\"],[0.5,\"month\"],[1,\"month\"],[2,\"month\"],[3,\"month\"],[6,\"month\"],[1,\"year\"]];var aC=0;if(aM.minTickSize!=null){if(typeof aM.tickSize==\"number\"){aC=aM.tickSize}else{aC=aM.minTickSize[0]*aJ[aM.minTickSize[1]]}}for(var aS=0;aS<aK.length-1;++aS){if(aT<(aK[aS][0]*aJ[aK[aS][1]]+aK[aS+1][0]*aJ[aK[aS+1][1]])/2&&aK[aS][0]*aJ[aK[aS][1]]>=aC){break}}aO=aK[aS][0];aN=aK[aS][1];if(aN==\"year\"){aQ=Math.pow(10,Math.floor(Math.log(aT/aJ.year)/Math.LN10));aI=(aT/aJ.year)/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ}aG.tickSize=aM.tickSize||[aO,aN];aB=function(aX){var a2=[],a0=aX.tickSize[0],a3=aX.tickSize[1],a1=new Date(aX.min);var aW=a0*aJ[a3];if(a3==\"second\"){a1.setUTCSeconds(a(a1.getUTCSeconds(),a0))}if(a3==\"minute\"){a1.setUTCMinutes(a(a1.getUTCMinutes(),a0))}if(a3==\"hour\"){a1.setUTCHours(a(a1.getUTCHours(),a0))}if(a3==\"month\"){a1.setUTCMonth(a(a1.getUTCMonth(),a0))}if(a3==\"year\"){a1.setUTCFullYear(a(a1.getUTCFullYear(),a0))}a1.setUTCMilliseconds(0);if(aW>=aJ.minute){a1.setUTCSeconds(0)}if(aW>=aJ.hour){a1.setUTCMinutes(0)}if(aW>=aJ.day){a1.setUTCHours(0)}if(aW>=aJ.day*4){a1.setUTCDate(1)}if(aW>=aJ.year){a1.setUTCMonth(0)}var a5=0,a4=Number.NaN,aY;do{aY=a4;a4=a1.getTime();a2.push(a4);if(a3==\"month\"){if(a0<1){a1.setUTCDate(1);var aV=a1.getTime();a1.setUTCMonth(a1.getUTCMonth()+1);var aZ=a1.getTime();a1.setTime(a4+a5*aJ.hour+(aZ-aV)*a0);a5=a1.getUTCHours();a1.setUTCHours(0)}else{a1.setUTCMonth(a1.getUTCMonth()+a0)}}else{if(a3==\"year\"){a1.setUTCFullYear(a1.getUTCFullYear()+a0)}else{a1.setTime(a4+aW)}}}while(a4<aX.max&&a4!=aY);return a2};aR=function(aV,aY){var a0=new Date(aV);if(aM.timeformat!=null){return c.plot.formatDate(a0,aM.timeformat,aM.monthNames)}var aW=aY.tickSize[0]*aJ[aY.tickSize[1]];var aX=aY.max-aY.min;var aZ=(aM.twelveHourClock)?\" %p\":\"\";if(aW<aJ.minute){fmt=\"%h:%M:%S\"+aZ}else{if(aW<aJ.day){if(aX<2*aJ.day){fmt=\"%h:%M\"+aZ}else{fmt=\"%b %d %h:%M\"+aZ}}else{if(aW<aJ.month){fmt=\"%b %d\"}else{if(aW<aJ.year){if(aX<aJ.year){fmt=\"%b\"}else{fmt=\"%b %y\"}}else{fmt=\"%y\"}}}}return c.plot.formatDate(a0,fmt,aM.monthNames)}}else{var aU=aM.tickDecimals;var aP=-Math.floor(Math.log(aT)/Math.LN10);if(aU!=null&&aP>aU){aP=aU}aQ=Math.pow(10,-aP);aI=aT/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2;if(aI>2.25&&(aU==null||aP+1<=aU)){aO=2.5;++aP}}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ;if(aM.minTickSize!=null&&aO<aM.minTickSize){aO=aM.minTickSize}aG.tickDecimals=Math.max(0,aU!=null?aU:aP);aG.tickSize=aM.tickSize||aO;aB=function(aX){var aZ=[];var a0=a(aX.min,aX.tickSize),aW=0,aV=Number.NaN,aY;do{aY=aV;aV=a0+aW*aX.tickSize;aZ.push(aV);++aW}while(aV<aX.max&&aV!=aY);return aZ};aR=function(aV,aW){return aV.toFixed(aW.tickDecimals)}}if(aM.alignTicksWithAxis!=null){var aF=(aG.direction==\"x\"?p:aw)[aM.alignTicksWithAxis-1];if(aF&&aF.used&&aF!=aG){var aL=aB(aG);if(aL.length>0){if(aM.min==null){aG.min=Math.min(aG.min,aL[0])}if(aM.max==null&&aL.length>1){aG.max=Math.max(aG.max,aL[aL.length-1])}}aB=function(aX){var aY=[],aV,aW;for(aW=0;aW<aF.ticks.length;++aW){aV=(aF.ticks[aW].v-aF.min)/(aF.max-aF.min);aV=aX.min+aV*(aX.max-aX.min);aY.push(aV)}return aY};if(aG.mode!=\"time\"&&aM.tickDecimals==null){var aE=Math.max(0,-Math.floor(Math.log(aT)/Math.LN10)+1),aD=aB(aG);if(!(aD.length>1&&/\\..*0$/.test((aD[1]-aD[0]).toFixed(aE)))){aG.tickDecimals=aE}}}}aG.tickGenerator=aB;if(c.isFunction(aM.tickFormatter)){aG.tickFormatter=function(aV,aW){return\"\"+aM.tickFormatter(aV,aW)}}else{aG.tickFormatter=aR}}function P(aF){var aH=aF.options.ticks,aG=[];if(aH==null||(typeof aH==\"number\"&&aH>0)){aG=aF.tickGenerator(aF)}else{if(aH){if(c.isFunction(aH)){aG=aH({min:aF.min,max:aF.max})}else{aG=aH}}}var aE,aB;aF.ticks=[];for(aE=0;aE<aG.length;++aE){var aC=null;var aD=aG[aE];if(typeof aD==\"object\"){aB=+aD[0];if(aD.length>1){aC=aD[1]}}else{aB=+aD}if(aC==null){aC=aF.tickFormatter(aB,aF)}if(!isNaN(aB)){aF.ticks.push({v:aB,label:aC})}}}function ap(aB,aC){if(aB.options.autoscaleMargin&&aC.length>0){if(aB.options.min==null){aB.min=Math.min(aB.min,aC[0].v)}if(aB.options.max==null&&aC.length>1){aB.max=Math.max(aB.max,aC[aC.length-1].v)}}}function W(){H.clearRect(0,0,G,I);var aC=O.grid;if(aC.show&&aC.backgroundColor){N()}if(aC.show&&!aC.aboveData){ac()}for(var aB=0;aB<Q.length;++aB){an(ak.drawSeries,[H,Q[aB]]);d(Q[aB])}an(ak.draw,[H]);if(aC.show&&aC.aboveData){ac()}}function D(aB,aI){var aE,aH,aG,aD,aF=m();for(i=0;i<aF.length;++i){aE=aF[i];if(aE.direction==aI){aD=aI+aE.n+\"axis\";if(!aB[aD]&&aE.n==1){aD=aI+\"axis\"}if(aB[aD]){aH=aB[aD].from;aG=aB[aD].to;break}}}if(!aB[aD]){aE=aI==\"x\"?p[0]:aw[0];aH=aB[aI+\"1\"];aG=aB[aI+\"2\"]}if(aH!=null&&aG!=null&&aH>aG){var aC=aH;aH=aG;aG=aC}return{from:aH,to:aG,axis:aE}}function N(){H.save();H.translate(q.left,q.top);H.fillStyle=am(O.grid.backgroundColor,w,0,\"rgba(255, 255, 255, 0)\");H.fillRect(0,0,h,w);H.restore()}function ac(){var aF;H.save();H.translate(q.left,q.top);var aH=O.grid.markings;if(aH){if(c.isFunction(aH)){var aK=aq.getAxes();aK.xmin=aK.xaxis.min;aK.xmax=aK.xaxis.max;aK.ymin=aK.yaxis.min;aK.ymax=aK.yaxis.max;aH=aH(aK)}for(aF=0;aF<aH.length;++aF){var aD=aH[aF],aC=D(aD,\"x\"),aI=D(aD,\"y\");if(aC.from==null){aC.from=aC.axis.min}if(aC.to==null){aC.to=aC.axis.max}if(aI.from==null){aI.from=aI.axis.min}if(aI.to==null){aI.to=aI.axis.max}if(aC.to<aC.axis.min||aC.from>aC.axis.max||aI.to<aI.axis.min||aI.from>aI.axis.max){continue}aC.from=Math.max(aC.from,aC.axis.min);aC.to=Math.min(aC.to,aC.axis.max);aI.from=Math.max(aI.from,aI.axis.min);aI.to=Math.min(aI.to,aI.axis.max);if(aC.from==aC.to&&aI.from==aI.to){continue}aC.from=aC.axis.p2c(aC.from);aC.to=aC.axis.p2c(aC.to);aI.from=aI.axis.p2c(aI.from);aI.to=aI.axis.p2c(aI.to);if(aC.from==aC.to||aI.from==aI.to){H.beginPath();H.strokeStyle=aD.color||O.grid.markingsColor;H.lineWidth=aD.lineWidth||O.grid.markingsLineWidth;H.moveTo(aC.from,aI.from);H.lineTo(aC.to,aI.to);H.stroke()}else{H.fillStyle=aD.color||O.grid.markingsColor;H.fillRect(aC.from,aI.to,aC.to-aC.from,aI.from-aI.to)}}}var aK=m(),aM=O.grid.borderWidth;for(var aE=0;aE<aK.length;++aE){var aB=aK[aE],aG=aB.box,aQ=aB.tickLength,aN,aL,aP,aJ;if(!aB.show||aB.ticks.length==0){continue}H.strokeStyle=aB.options.tickColor||c.color.parse(aB.options.color).scale(\"a\",0.22).toString();H.lineWidth=1;if(aB.direction==\"x\"){aN=0;if(aQ==\"full\"){aL=(aB.position==\"top\"?0:w)}else{aL=aG.top-q.top+(aB.position==\"top\"?aG.height:0)}}else{aL=0;if(aQ==\"full\"){aN=(aB.position==\"left\"?0:h)}else{aN=aG.left-q.left+(aB.position==\"left\"?aG.width:0)}}if(!aB.innermost){H.beginPath();aP=aJ=0;if(aB.direction==\"x\"){aP=h}else{aJ=w}if(H.lineWidth==1){aN=Math.floor(aN)+0.5;aL=Math.floor(aL)+0.5}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ);H.stroke()}H.beginPath();for(aF=0;aF<aB.ticks.length;++aF){var aO=aB.ticks[aF].v;aP=aJ=0;if(aO<aB.min||aO>aB.max||(aQ==\"full\"&&aM>0&&(aO==aB.min||aO==aB.max))){continue}if(aB.direction==\"x\"){aN=aB.p2c(aO);aJ=aQ==\"full\"?-w:aQ;if(aB.position==\"top\"){aJ=-aJ}}else{aL=aB.p2c(aO);aP=aQ==\"full\"?-h:aQ;if(aB.position==\"left\"){aP=-aP}}if(H.lineWidth==1){if(aB.direction==\"x\"){aN=Math.floor(aN)+0.5}else{aL=Math.floor(aL)+0.5}}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ)}H.stroke()}if(aM){H.lineWidth=aM;H.strokeStyle=O.grid.borderColor;H.strokeRect(-aM/2,-aM/2,h+aM,w+aM)}H.restore()}function k(){av.find(\".tickLabels\").remove();var aG=['<div class=\"tickLabels\" style=\"font-size:smaller\">'];var aJ=m();for(var aD=0;aD<aJ.length;++aD){var aC=aJ[aD],aF=aC.box;if(!aC.show){continue}aG.push('<div class=\"'+aC.direction+\"Axis \"+aC.direction+aC.n+'Axis\" style=\"color:'+aC.options.color+'\">');for(var aE=0;aE<aC.ticks.length;++aE){var aH=aC.ticks[aE];if(!aH.label||aH.v<aC.min||aH.v>aC.max){continue}var aK={},aI;if(aC.direction==\"x\"){aI=\"center\";aK.left=Math.round(q.left+aC.p2c(aH.v)-aC.labelWidth/2);if(aC.position==\"bottom\"){aK.top=aF.top+aF.padding}else{aK.bottom=I-(aF.top+aF.height-aF.padding)}}else{aK.top=Math.round(q.top+aC.p2c(aH.v)-aC.labelHeight/2);if(aC.position==\"left\"){aK.right=G-(aF.left+aF.width-aF.padding);aI=\"right\"}else{aK.left=aF.left+aF.padding;aI=\"left\"}}aK.width=aC.labelWidth;var aB=[\"position:absolute\",\"text-align:\"+aI];for(var aL in aK){aB.push(aL+\":\"+aK[aL]+\"px\")}aG.push('<div class=\"tickLabel\" style=\"'+aB.join(\";\")+'\">'+aH.label+\"</div>\")}aG.push(\"</div>\")}aG.push(\"</div>\");av.append(aG.join(\"\"))}function d(aB){if(aB.lines.show){at(aB)}if(aB.bars.show){e(aB)}if(aB.points.show){ao(aB)}}function at(aE){function aD(aP,aQ,aI,aU,aT){var aV=aP.points,aJ=aP.pointsize,aN=null,aM=null;H.beginPath();for(var aO=aJ;aO<aV.length;aO+=aJ){var aL=aV[aO-aJ],aS=aV[aO-aJ+1],aK=aV[aO],aR=aV[aO+1];if(aL==null||aK==null){continue}if(aS<=aR&&aS<aT.min){if(aR<aT.min){continue}aL=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.min}else{if(aR<=aS&&aR<aT.min){if(aS<aT.min){continue}aK=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.min}}if(aS>=aR&&aS>aT.max){if(aR>aT.max){continue}aL=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.max}else{if(aR>=aS&&aR>aT.max){if(aS>aT.max){continue}aK=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.max}}if(aL<=aK&&aL<aU.min){if(aK<aU.min){continue}aS=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.min}else{if(aK<=aL&&aK<aU.min){if(aL<aU.min){continue}aR=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.min}}if(aL>=aK&&aL>aU.max){if(aK>aU.max){continue}aS=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.max}else{if(aK>=aL&&aK>aU.max){if(aL>aU.max){continue}aR=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.max}}if(aL!=aN||aS!=aM){H.moveTo(aU.p2c(aL)+aQ,aT.p2c(aS)+aI)}aN=aK;aM=aR;H.lineTo(aU.p2c(aK)+aQ,aT.p2c(aR)+aI)}H.stroke()}function aF(aI,aQ,aP){var aW=aI.points,aV=aI.pointsize,aN=Math.min(Math.max(0,aP.min),aP.max),aX=0,aU,aT=false,aM=1,aL=0,aR=0;while(true){if(aV>0&&aX>aW.length+aV){break}aX+=aV;var aZ=aW[aX-aV],aK=aW[aX-aV+aM],aY=aW[aX],aJ=aW[aX+aM];if(aT){if(aV>0&&aZ!=null&&aY==null){aR=aX;aV=-aV;aM=2;continue}if(aV<0&&aX==aL+aV){H.fill();aT=false;aV=-aV;aM=1;aX=aL=aR+aV;continue}}if(aZ==null||aY==null){continue}if(aZ<=aY&&aZ<aQ.min){if(aY<aQ.min){continue}aK=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.min}else{if(aY<=aZ&&aY<aQ.min){if(aZ<aQ.min){continue}aJ=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.min}}if(aZ>=aY&&aZ>aQ.max){if(aY>aQ.max){continue}aK=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.max}else{if(aY>=aZ&&aY>aQ.max){if(aZ>aQ.max){continue}aJ=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.max}}if(!aT){H.beginPath();H.moveTo(aQ.p2c(aZ),aP.p2c(aN));aT=true}if(aK>=aP.max&&aJ>=aP.max){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.max));H.lineTo(aQ.p2c(aY),aP.p2c(aP.max));continue}else{if(aK<=aP.min&&aJ<=aP.min){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.min));H.lineTo(aQ.p2c(aY),aP.p2c(aP.min));continue}}var aO=aZ,aS=aY;if(aK<=aJ&&aK<aP.min&&aJ>=aP.min){aZ=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.min}else{if(aJ<=aK&&aJ<aP.min&&aK>=aP.min){aY=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.min}}if(aK>=aJ&&aK>aP.max&&aJ<=aP.max){aZ=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.max}else{if(aJ>=aK&&aJ>aP.max&&aK<=aP.max){aY=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.max}}if(aZ!=aO){H.lineTo(aQ.p2c(aO),aP.p2c(aK))}H.lineTo(aQ.p2c(aZ),aP.p2c(aK));H.lineTo(aQ.p2c(aY),aP.p2c(aJ));if(aY!=aS){H.lineTo(aQ.p2c(aY),aP.p2c(aJ));H.lineTo(aQ.p2c(aS),aP.p2c(aJ))}}}H.save();H.translate(q.left,q.top);H.lineJoin=\"round\";var aG=aE.lines.lineWidth,aB=aE.shadowSize;if(aG>0&&aB>0){H.lineWidth=aB;H.strokeStyle=\"rgba(0,0,0,0.1)\";var aH=Math.PI/18;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/2),Math.cos(aH)*(aG/2+aB/2),aE.xaxis,aE.yaxis);H.lineWidth=aB/2;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/4),Math.cos(aH)*(aG/2+aB/4),aE.xaxis,aE.yaxis)}H.lineWidth=aG;H.strokeStyle=aE.color;var aC=ae(aE.lines,aE.color,0,w);if(aC){H.fillStyle=aC;aF(aE.datapoints,aE.xaxis,aE.yaxis)}if(aG>0){aD(aE.datapoints,0,0,aE.xaxis,aE.yaxis)}H.restore()}function ao(aE){function aH(aN,aM,aU,aK,aS,aT,aQ,aJ){var aR=aN.points,aI=aN.pointsize;for(var aL=0;aL<aR.length;aL+=aI){var aP=aR[aL],aO=aR[aL+1];if(aP==null||aP<aT.min||aP>aT.max||aO<aQ.min||aO>aQ.max){continue}H.beginPath();aP=aT.p2c(aP);aO=aQ.p2c(aO)+aK;if(aJ==\"circle\"){H.arc(aP,aO,aM,0,aS?Math.PI:Math.PI*2,false)}else{aJ(H,aP,aO,aM,aS)}H.closePath();if(aU){H.fillStyle=aU;H.fill()}H.stroke()}}H.save();H.translate(q.left,q.top);var aG=aE.points.lineWidth,aC=aE.shadowSize,aB=aE.points.radius,aF=aE.points.symbol;if(aG>0&&aC>0){var aD=aC/2;H.lineWidth=aD;H.strokeStyle=\"rgba(0,0,0,0.1)\";aH(aE.datapoints,aB,null,aD+aD/2,true,aE.xaxis,aE.yaxis,aF);H.strokeStyle=\"rgba(0,0,0,0.2)\";aH(aE.datapoints,aB,null,aD/2,true,aE.xaxis,aE.yaxis,aF)}H.lineWidth=aG;H.strokeStyle=aE.color;aH(aE.datapoints,aB,ae(aE.points,aE.color),0,false,aE.xaxis,aE.yaxis,aF);H.restore()}function E(aN,aM,aV,aI,aQ,aF,aD,aL,aK,aU,aR,aC){var aE,aT,aJ,aP,aG,aB,aO,aH,aS;if(aR){aH=aB=aO=true;aG=false;aE=aV;aT=aN;aP=aM+aI;aJ=aM+aQ;if(aT<aE){aS=aT;aT=aE;aE=aS;aG=true;aB=false}}else{aG=aB=aO=true;aH=false;aE=aN+aI;aT=aN+aQ;aJ=aV;aP=aM;if(aP<aJ){aS=aP;aP=aJ;aJ=aS;aH=true;aO=false}}if(aT<aL.min||aE>aL.max||aP<aK.min||aJ>aK.max){return}if(aE<aL.min){aE=aL.min;aG=false}if(aT>aL.max){aT=aL.max;aB=false}if(aJ<aK.min){aJ=aK.min;aH=false}if(aP>aK.max){aP=aK.max;aO=false}aE=aL.p2c(aE);aJ=aK.p2c(aJ);aT=aL.p2c(aT);aP=aK.p2c(aP);if(aD){aU.beginPath();aU.moveTo(aE,aJ);aU.lineTo(aE,aP);aU.lineTo(aT,aP);aU.lineTo(aT,aJ);aU.fillStyle=aD(aJ,aP);aU.fill()}if(aC>0&&(aG||aB||aO||aH)){aU.beginPath();aU.moveTo(aE,aJ+aF);if(aG){aU.lineTo(aE,aP+aF)}else{aU.moveTo(aE,aP+aF)}if(aO){aU.lineTo(aT,aP+aF)}else{aU.moveTo(aT,aP+aF)}if(aB){aU.lineTo(aT,aJ+aF)}else{aU.moveTo(aT,aJ+aF)}if(aH){aU.lineTo(aE,aJ+aF)}else{aU.moveTo(aE,aJ+aF)}aU.stroke()}}function e(aD){function aC(aJ,aI,aL,aG,aK,aN,aM){var aO=aJ.points,aF=aJ.pointsize;for(var aH=0;aH<aO.length;aH+=aF){if(aO[aH]==null){continue}E(aO[aH],aO[aH+1],aO[aH+2],aI,aL,aG,aK,aN,aM,H,aD.bars.horizontal,aD.bars.lineWidth)}}H.save();H.translate(q.left,q.top);H.lineWidth=aD.bars.lineWidth;H.strokeStyle=aD.color;var aB=aD.bars.align==\"left\"?0:-aD.bars.barWidth/2;var aE=aD.bars.fill?function(aF,aG){return ae(aD.bars,aD.color,aF,aG)}:null;aC(aD.datapoints,aB,aB+aD.bars.barWidth,0,aE,aD.xaxis,aD.yaxis);H.restore()}function ae(aD,aB,aC,aF){var aE=aD.fill;if(!aE){return null}if(aD.fillColor){return am(aD.fillColor,aC,aF,aB)}var aG=c.color.parse(aB);aG.a=typeof aE==\"number\"?aE:0.4;aG.normalize();return aG.toString()}function o(){av.find(\".legend\").remove();if(!O.legend.show){return}var aH=[],aF=false,aN=O.legend.labelFormatter,aM,aJ;for(var aE=0;aE<Q.length;++aE){aM=Q[aE];aJ=aM.label;if(!aJ){continue}if(aE%O.legend.noColumns==0){if(aF){aH.push(\"</tr>\")}aH.push(\"<tr>\");aF=true}if(aN){aJ=aN(aJ,aM)}aH.push('<td class=\"legendColorBox\"><div style=\"border:1px solid '+O.legend.labelBoxBorderColor+';padding:1px\"><div style=\"width:4px;height:0;border:5px solid '+aM.color+';overflow:hidden\"></div></div></td><td class=\"legendLabel\">'+aJ+\"</td>\")}if(aF){aH.push(\"</tr>\")}if(aH.length==0){return}var aL='<table style=\"font-size:smaller;color:'+O.grid.color+'\">'+aH.join(\"\")+\"</table>\";if(O.legend.container!=null){c(O.legend.container).html(aL)}else{var aI=\"\",aC=O.legend.position,aD=O.legend.margin;if(aD[0]==null){aD=[aD,aD]}if(aC.charAt(0)==\"n\"){aI+=\"top:\"+(aD[1]+q.top)+\"px;\"}else{if(aC.charAt(0)==\"s\"){aI+=\"bottom:\"+(aD[1]+q.bottom)+\"px;\"}}if(aC.charAt(1)==\"e\"){aI+=\"right:\"+(aD[0]+q.right)+\"px;\"}else{if(aC.charAt(1)==\"w\"){aI+=\"left:\"+(aD[0]+q.left)+\"px;\"}}var aK=c('<div class=\"legend\">'+aL.replace('style=\"','style=\"position:absolute;'+aI+\";\")+\"</div>\").appendTo(av);if(O.legend.backgroundOpacity!=0){var aG=O.legend.backgroundColor;if(aG==null){aG=O.grid.backgroundColor;if(aG&&typeof aG==\"string\"){aG=c.color.parse(aG)}else{aG=c.color.extract(aK,\"background-color\")}aG.a=1;aG=aG.toString()}var aB=aK.children();c('<div style=\"position:absolute;width:'+aB.width()+\"px;height:\"+aB.height()+\"px;\"+aI+\"background-color:\"+aG+';\"> </div>').prependTo(aK).css(\"opacity\",O.legend.backgroundOpacity)}}}var ab=[],M=null;function K(aI,aG,aD){var aO=O.grid.mouseActiveRadius,a0=aO*aO+1,aY=null,aR=false,aW,aU;for(aW=Q.length-1;aW>=0;--aW){if(!aD(Q[aW])){continue}var aP=Q[aW],aH=aP.xaxis,aF=aP.yaxis,aV=aP.datapoints.points,aT=aP.datapoints.pointsize,aQ=aH.c2p(aI),aN=aF.c2p(aG),aC=aO/aH.scale,aB=aO/aF.scale;if(aH.options.inverseTransform){aC=Number.MAX_VALUE}if(aF.options.inverseTransform){aB=Number.MAX_VALUE}if(aP.lines.show||aP.points.show){for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1];if(aK==null){continue}if(aK-aQ>aC||aK-aQ<-aC||aJ-aN>aB||aJ-aN<-aB){continue}var aM=Math.abs(aH.p2c(aK)-aI),aL=Math.abs(aF.p2c(aJ)-aG),aS=aM*aM+aL*aL;if(aS<a0){a0=aS;aY=[aW,aU/aT]}}}if(aP.bars.show&&!aY){var aE=aP.bars.align==\"left\"?0:-aP.bars.barWidth/2,aX=aE+aP.bars.barWidth;for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1],aZ=aV[aU+2];if(aK==null){continue}if(Q[aW].bars.horizontal?(aQ<=Math.max(aZ,aK)&&aQ>=Math.min(aZ,aK)&&aN>=aJ+aE&&aN<=aJ+aX):(aQ>=aK+aE&&aQ<=aK+aX&&aN>=Math.min(aZ,aJ)&&aN<=Math.max(aZ,aJ))){aY=[aW,aU/aT]}}}}if(aY){aW=aY[0];aU=aY[1];aT=Q[aW].datapoints.pointsize;return{datapoint:Q[aW].datapoints.points.slice(aU*aT,(aU+1)*aT),dataIndex:aU,series:Q[aW],seriesIndex:aW}}return null}function aa(aB){if(O.grid.hoverable){u(\"plothover\",aB,function(aC){return aC.hoverable!=false})}}function l(aB){if(O.grid.hoverable){u(\"plothover\",aB,function(aC){return false})}}function R(aB){u(\"plotclick\",aB,function(aC){return aC.clickable!=false})}function u(aC,aB,aD){var aE=y.offset(),aH=aB.pageX-aE.left-q.left,aF=aB.pageY-aE.top-q.top,aJ=C({left:aH,top:aF});aJ.pageX=aB.pageX;aJ.pageY=aB.pageY;var aK=K(aH,aF,aD);if(aK){aK.pageX=parseInt(aK.series.xaxis.p2c(aK.datapoint[0])+aE.left+q.left);aK.pageY=parseInt(aK.series.yaxis.p2c(aK.datapoint[1])+aE.top+q.top)}if(O.grid.autoHighlight){for(var aG=0;aG<ab.length;++aG){var aI=ab[aG];if(aI.auto==aC&&!(aK&&aI.series==aK.series&&aI.point[0]==aK.datapoint[0]&&aI.point[1]==aK.datapoint[1])){T(aI.series,aI.point)}}if(aK){x(aK.series,aK.datapoint,aC)}}av.trigger(aC,[aJ,aK])}function f(){if(!M){M=setTimeout(s,30)}}function s(){M=null;A.save();A.clearRect(0,0,G,I);A.translate(q.left,q.top);var aC,aB;for(aC=0;aC<ab.length;++aC){aB=ab[aC];if(aB.series.bars.show){v(aB.series,aB.point)}else{ay(aB.series,aB.point)}}A.restore();an(ak.drawOverlay,[A])}function x(aD,aB,aF){if(typeof aD==\"number\"){aD=Q[aD]}if(typeof aB==\"number\"){var aE=aD.datapoints.pointsize;aB=aD.datapoints.points.slice(aE*aB,aE*(aB+1))}var aC=al(aD,aB);if(aC==-1){ab.push({series:aD,point:aB,auto:aF});f()}else{if(!aF){ab[aC].auto=false}}}function T(aD,aB){if(aD==null&&aB==null){ab=[];f()}if(typeof aD==\"number\"){aD=Q[aD]}if(typeof aB==\"number\"){aB=aD.data[aB]}var aC=al(aD,aB);if(aC!=-1){ab.splice(aC,1);f()}}function al(aD,aE){for(var aB=0;aB<ab.length;++aB){var aC=ab[aB];if(aC.series==aD&&aC.point[0]==aE[0]&&aC.point[1]==aE[1]){return aB}}return -1}function ay(aE,aD){var aC=aD[0],aI=aD[1],aH=aE.xaxis,aG=aE.yaxis;if(aC<aH.min||aC>aH.max||aI<aG.min||aI>aG.max){return}var aF=aE.points.radius+aE.points.lineWidth/2;A.lineWidth=aF;A.strokeStyle=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aB=1.5*aF,aC=aH.p2c(aC),aI=aG.p2c(aI);A.beginPath();if(aE.points.symbol==\"circle\"){A.arc(aC,aI,aB,0,2*Math.PI,false)}else{aE.points.symbol(A,aC,aI,aB,false)}A.closePath();A.stroke()}function v(aE,aB){A.lineWidth=aE.bars.lineWidth;A.strokeStyle=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aD=c.color.parse(aE.color).scale(\"a\",0.5).toString();var aC=aE.bars.align==\"left\"?0:-aE.bars.barWidth/2;E(aB[0],aB[1],aB[2]||0,aC,aC+aE.bars.barWidth,0,function(){return aD},aE.xaxis,aE.yaxis,A,aE.bars.horizontal,aE.bars.lineWidth)}function am(aJ,aB,aH,aC){if(typeof aJ==\"string\"){return aJ}else{var aI=H.createLinearGradient(0,aH,0,aB);for(var aE=0,aD=aJ.colors.length;aE<aD;++aE){var aF=aJ.colors[aE];if(typeof aF!=\"string\"){var aG=c.color.parse(aC);if(aF.brightness!=null){aG=aG.scale(\"rgb\",aF.brightness)}if(aF.opacity!=null){aG.a*=aF.opacity}aF=aG.toString()}aI.addColorStop(aE/(aD-1),aF)}return aI}}}c.plot=function(g,e,d){var f=new b(c(g),e,d,c.plot.plugins);return f};c.plot.version=\"0.7\";c.plot.plugins=[];c.plot.formatDate=function(l,f,h){var o=function(d){d=\"\"+d;return d.length==1?\"0\"+d:d};var e=[];var p=false,j=false;var n=l.getUTCHours();var k=n<12;if(h==null){h=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"]}if(f.search(/%p|%P/)!=-1){if(n>12){n=n-12}else{if(n==0){n=12}}}for(var g=0;g<f.length;++g){var m=f.charAt(g);if(p){switch(m){case\"h\":m=\"\"+n;break;case\"H\":m=o(n);break;case\"M\":m=o(l.getUTCMinutes());break;case\"S\":m=o(l.getUTCSeconds());break;case\"d\":m=\"\"+l.getUTCDate();break;case\"m\":m=\"\"+(l.getUTCMonth()+1);break;case\"y\":m=\"\"+l.getUTCFullYear();break;case\"b\":m=\"\"+h[l.getUTCMonth()];break;case\"p\":m=(k)?(\"am\"):(\"pm\");break;case\"P\":m=(k)?(\"AM\"):(\"PM\");break;case\"0\":m=\"\";j=true;break}if(m&&j){m=o(m);j=false}e.push(m);if(!j){p=false}}else{if(m==\"%\"){p=true}else{e.push(m)}}}return e.join(\"\")};function a(e,d){return d*Math.floor(e/d)}})(jQuery);", | |
"", | |
"(function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger(\"plotselecting\",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one(\"mouseup\",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger(\"plotunselected\",[]);k.getPlaceholder().trigger(\"plotselecting\",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger(\"plotselected\",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger(\"selected\",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode==\"y\"){w.x=w==p.first?0:k.width()}if(v.selection.mode==\"x\"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger(\"plotunselected\",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+\"axis\";if(!s[A]&&t.n==1){A=w+\"axis\"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w==\"x\"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+\"1\"];z=s[w+\"2\"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode==\"y\"){p.first.x=0;p.second.x=k.width()}else{u=c(t,\"x\");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode==\"x\"){p.first.y=0;p.second.y=k.height()}else{u=c(t,\"y\");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale(\"a\",0.8).toString();D.lineWidth=1;D.lineJoin=\"round\";D.fillStyle=z.scale(\"a\",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind(\"mousemove\",e);s.unbind(\"mousedown\",n);if(r){a(document).unbind(\"mouseup\",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:\"#e8cfac\"}},name:\"selection\",version:\"1.1\"})})(jQuery);", | |
"" | |
], | |
"output_type": "display_data", | |
"text": [ | |
"<IPython.core.display.Javascript at 0x2e09ed0>" | |
] | |
} | |
], | |
"prompt_number": 23 | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"In order to use the flot bindings it is necessary to create an instance of Plot()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"plt = Plot()" | |
], | |
"language": "python", | |
"outputs": [], | |
"prompt_number": 24 | |
}, | |
{ | |
"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", | |
"collapsed": false, | |
"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 0x2df8450>" | |
] | |
}, | |
{ | |
"javascript": [ | |
"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 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 0x2df8450>" | |
] | |
} | |
], | |
"prompt_number": 25 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"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 0x2df80d0>" | |
] | |
}, | |
{ | |
"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 0x2df80d0>" | |
] | |
} | |
], | |
"prompt_number": 26 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"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 0x2528e50>" | |
] | |
}, | |
{ | |
"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 0x2528e50>" | |
] | |
} | |
], | |
"prompt_number": 15 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"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 0x2528a10>" | |
] | |
}, | |
{ | |
"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 0x2528a10>" | |
] | |
} | |
], | |
"prompt_number": 16 | |
}, | |
{ | |
"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", | |
"collapsed": false, | |
"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 0x2e02150>" | |
] | |
}, | |
{ | |
"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 0x2e02150>" | |
] | |
} | |
], | |
"prompt_number": 17 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": true, | |
"input": [ | |
"" | |
], | |
"language": "python", | |
"outputs": [] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment