draw_axes=function(xlabel,ylabel,precision=[2,2]){
var ctx = this.canvas.node().getContext('2d')
ctx.font = '8px sans-serif';
ctx.strokeStyle = 'black'
var dx,dy,x0,y0
x0=this.xlim[0]
y0=this.ylim[0]
if (this.xscale=='linear'){dx=this.xlim[1]-this.xlim[0]}
if (this.yscale=='linear'){dy=this.ylim[1]-this.ylim[0]}
var DeltaX,DeltaY
var xsigma=Math.floor(dx*Math.pow(10,1-Math.floor(Math.log10(dx))))
var ysigma=Math.floor(dy*Math.pow(10,1-Math.floor(Math.log10(dy))))
if (xsigma>50){DeltaX=10*Math.pow(10,-1+Math.floor(Math.log10(dx)))}
else if (xsigma>30){DeltaX=5*Math.pow(10,-1+Math.floor(Math.log10(dx)))}
else{DeltaX=2*Math.pow(10,-1+Math.floor(Math.log10(dx)))}
if (ysigma>50){DeltaY=10*Math.pow(10,-1+Math.floor(Math.log10(dy)))}
else if (ysigma>30){DeltaY=5*Math.pow(10,-1+Math.floor(Math.log10(dy)))}
else{DeltaY=2*Math.pow(10,-1+Math.floor(Math.log10(dy)))}
var tick
if (this.xscale=='linear'){
for (var i = 0; i < Math.floor(dx/DeltaX); i++) {
tick=Math.floor(x0/DeltaX)*DeltaX + (i+1)*DeltaX
ctx.beginPath();
ctx.moveTo(this.xax(tick),this.yax(this.ylim[0]));
ctx.lineTo(this.xax(tick),this.yax(this.ylim[0]+dy/100));
ctx.stroke();
ctx.fillText(Number.parseFloat(tick).toPrecision(precision[0]),
this.xax(tick+dx/200),this.yax(this.ylim[0]+dy/100))
}
}
if (this.xscale=='log'){
var smallPow=Math.floor(Math.log10(this.xlim[0]))
var smallVal=(Math.floor(0.99999*x0/(10**smallPow))+1)
var largePow=Math.floor(Math.log10(this.xlim[1]))
var largeVal=(Math.floor(1.00001*this.xlim[1]/(10**largePow))+1)
var lower,upper
var tickHeight
var tickLabel
for (var i=smallPow; i<largePow+1;i++){
if (i==smallVal){lower=smallVal}
else{ lower=1 }
if (i==largeVal){upper=largeVal}
else{ upper=9 }
for (var j=lower;j<upper+1;j++){
ctx.beginPath();
ctx.moveTo(this.xax(j*(10**i)),this.yax(this.ylim[0]));
if (j!=1){
tickHeight=10**(0.995*Math.log10(this.ylim[0])+0.005*Math.log10(this.ylim[1]))
ctx.lineTo(this.xax(j*(10**i)),this.yax(tickHeight))
ctx.stroke()
}
if (j==1){
tickHeight=10**(0.99*Math.log10(this.ylim[0])+0.01*Math.log10(this.ylim[1]))
ctx.lineTo(this.xax(j*(10**i)),this.yax(tickHeight))
ctx.stroke()
ctx.fillText('10^'+i,this.xax(1.05*j*(10**i)),this.yax(tickHeight))
}
}
}
}
if (this.yscale=='linear'){
for (var i = 0; i < Math.floor(dy/DeltaY)+1; i++) {
if (precision[1]>0){
tick=Math.floor(y0/DeltaY)*DeltaY + (i+1)*DeltaY
ctx.beginPath();
ctx.moveTo(this.xax(this.xlim[0]),this.yax(tick));
ctx.lineTo(this.xax(this.xlim[0]+dx/100),this.yax(tick));
ctx.stroke();
ctx.fillText(Number.parseFloat(tick).toPrecision(precision[1]),
this.xax(this.xlim[0]+dx/100),this.yax(tick+dy/200))
}
}
}
if (this.yscale=='log'){
var smallPow=Math.floor(Math.log10(this.ylim[0]))
var smallVal=(Math.floor(0.99999*y0/(10**smallPow))+1)
var largePow=Math.floor(Math.log10(this.ylim[1]))
var largeVal=(Math.floor(1.00001*this.ylim[1]/(10**largePow))+1)
var lower,upper
var tickHeight
var tickLabel
for (var i=smallPow; i<largePow+1;i++){
if (i==smallVal){lower=smallVal}
else{ lower=1 }
if (i==largeVal){upper=largeVal}
else{ upper=9 }
for (var j=lower;j<upper+1;j++){
ctx.beginPath();
ctx.moveTo(this.xax(this.xlim[0]),this.yax(j*(10**i)));
if (j!=1){
tickHeight=10**(0.995*Math.log10(this.xlim[0])+0.005*Math.log10(this.xlim[1]))
ctx.lineTo(this.xax(tickHeight),this.yax(j*(10**i)))
ctx.stroke()
}
if (j==1){
tickHeight=10**(0.99*Math.log10(this.xlim[0])+0.01*Math.log10(this.xlim[1]))
ctx.lineTo(this.xax(tickHeight),this.yax(j*(10**i)))
ctx.stroke()
ctx.fillText('10^'+i,this.xax(tickHeight),this.yax(1.05*j*(10**i)))
}
}
}
}
ctx.textAlign = "end";
ctx.font = 'bold 12px sans-serif';
ctx.fillStyle='black'
ctx.fillText(xlabel,this.xax(this.xlim[1])-8,this.yax(this.ylim[0])-10)
ctx.textAlign = "start";
ctx.fillText(ylabel,this.xax(this.xlim[0])+8,this.yax(this.ylim[1])+10)
ctx.font = '8px sans-serif';
ctx.beginPath();
ctx.moveTo(this.xax(this.xlim[0]),this.yax(this.ylim[0]));
ctx.lineTo(this.xax(this.xlim[1]),this.yax(this.ylim[0]));
ctx.stroke();
ctx.beginPath();
ctx.moveTo(this.xax(this.xlim[0]),this.yax(this.ylim[0]));
ctx.lineTo(this.xax(this.xlim[0]),this.yax(this.ylim[1]));
ctx.stroke();
}