Index: /issm/trunk-jpl/src/m/plot/applyoptions.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 20789)
+++ /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 20790)
@@ -17,9 +17,10 @@
 			var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			var colorbarorientiation = options.getfieldvalue('colorbarorientation','vertical');
+			var colorbarinnerlabels = options.getfieldvalue('colorbarinnerlabels','off');
 			var cheightoffset = options.getfieldvalue('colorbarfontsize',18);
 			var cwidthoffset = options.getfieldvalue('colorbarfontsize',18)*3;
 			var cwidthscale = 0.5; //Default size of actual colorbar width, relative to canvas width (range [0,1])
 			var cheightscale = 0.875; //Default size of actual colorbar height, relative to canvas height (range [0,1])
-			var ccontext,ccanvas,ccanvasid,ccanvashtml,cheight,cwidth,color,y,x;
+			var ccontext,ccanvas,ccanvasid,ccanvashtml,cheight,cwidth,color,y,x,cgradient,cmap,colorbar,textAlign,a,b,c,d,e,f,g,h;
 			//}}}
 			//Set colorbar lables {{{
@@ -39,86 +40,88 @@
 				}
 			} //}}}
+			ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid')+'_colorbar');
+			ccanvashtml = document.getElementById(ccanvasid);
+			ccanvas = $('#'+ccanvasid);
+			ccontext = ccanvas[0].getContext('2d');
+			ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height);
+			ccontext.beginPath();
+			cmap = options.getfieldvalue('colormap','jet');
+			colorbar = colorbars[cmap];
 			//Handle orientation {{{
-			if (colorbarorientiation=='vertical') { //{{{
-				ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid')+'_colorbar');
-				ccanvashtml = document.getElementById(ccanvasid);
+			if (colorbarorientiation=='vertical') {
 				cwidth = ccanvashtml.width*cwidthscale*options.getfieldvalue('colorbarwidth',1);
 				cheight = ccanvashtml.height*cheightscale*options.getfieldvalue('colorbarheight',1);
-				ccanvas = $('#'+ccanvasid);
-				ccontext = ccanvas[0].getContext('2d');
-				ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height);
-				ccontext.beginPath();
-
-				var cgradient = ccontext.createLinearGradient(0,cheightoffset/2,0,cheight);
-				var cmap = options.getfieldvalue('colormap','jet');
-				var colorbar = colorbars[cmap];
-				for (var i=0; i < colorbar.length; i++) {
-					color = colorbar[colorbar.length-i-1];
-					color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
-					cgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
-				}
-				ccontext.fillStyle=cgradient;
-				ccontext.fillRect(0,cheightoffset*3/2,cwidth,cheight);
-				
-				//Draw colorbar border
-				ccontext.beginPath();
-				ccontext.lineWidth='1';
-				ccontext.strokeStyle=options.getfieldvalue('colorbarfontcolor','black');
-				ccontext.rect(0,cheightoffset*3/2,cwidth,cheight);
-				ccontext.stroke();
-				
+				cgradient = ccontext.createLinearGradient(0,cheightoffset/2,0,cheight);
+				textAlign = 'left';
+				a = 0;
+				b = cheightoffset*3/2;
+				c = 0;
+			}
+			else {
+				cwidth = ccanvashtml.width*0.7*options.getfieldvalue('colorbarwidth',1);
+				cheight = ccanvashtml.height*0.4*options.getfieldvalue('colorbarheight',1);
+				cgradient = ccontext.createLinearGradient(cwidth+cwidthoffset,0,cwidthoffset,0);		
+				textAlign = 'center';
+				a = cwidthoffset;
+				b = cheightoffset;
+				c = cwidth/2+cwidthoffset;
+			} //}}}
+			//Handle internal labels {{{
+			if (colorbarinnerlabels=='on') {
+				textAlign = 'center';
+				d = (cdivisions/(cdivisions+1.0));
+				e = (1.0/(cdivisions+1.0));
+				f = 2;
+				g = 1;
+				h = cwidth/2;
+			}
+			else {
+				d = 1;
+				e = 0;
+				f = 1;
+				g = 0;
+				h = cwidth+0.2*cwidth;
+			} //}}}
+
+			for (var i=0; i < colorbar.length; i++) {
+				color = colorbar[colorbar.length-i-1];
+				color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
+				cgradient.addColorStop(i/colorbar.length*d+e,'rgba('+color.toString()+',1.0)');
+			}
+			ccontext.fillStyle=cgradient;
+			ccontext.fillRect(a,b,cwidth,cheight);
+			
+			//Draw colorbar border
+			ccontext.beginPath();
+			ccontext.lineWidth='1';
+			ccontext.strokeStyle=options.getfieldvalue('colorbarfontcolor','black');
+			ccontext.rect(a,b,cwidth,cheight);
+			ccontext.stroke();
+			
+			if (colorbarorientiation=='vertical') { //{{{
 				for (var i=0; i <= cdivisions; i++) {
-					y = i/cdivisions*cheight+cheightoffset/2;
+					y = i/(cdivisions+g)*cheight+cheightoffset/2;
 					x = 0.2*cwidth;
-					ccontext.beginPath();
-					ccontext.moveTo(0,y+cheightoffset);
-					ccontext.lineTo(x,y+cheightoffset);
-					ccontext.moveTo(cwidth-x,y+cheightoffset);
-					ccontext.lineTo(cwidth,y+cheightoffset);
-					ccontext.stroke();
 					ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
 					ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
-					ccontext.textAlign='left';
-					ccontext.fillText(labels[i],cwidth+x,y+cheightoffset*3/2);
-				}
-				if (options.exist('colorbartitle')) {
-					ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
-					ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
-					ccontext.textAlign='left';
-					ccontext.textBaseline='bottom';
-					ccontext.fillText(options.getfieldvalue('colorbartitle'),0,cheightoffset);
-				}
-			} //}}}
-			else { //colorbarorientiation=='horizontal' {{{
-				ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid')+'_colorbar');
-				ccanvashtml = document.getElementById(ccanvasid);
-				cwidth = ccanvashtml.width*0.7*options.getfieldvalue('colorbarwidth',1);
-				cheight = ccanvashtml.height*0.4*options.getfieldvalue('colorbarheight',1);
-				ccanvas = $('#'+ccanvasid);
-				ccontext = ccanvas[0].getContext('2d');
-				ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height);
-				ccontext.beginPath();
-
-				var cgradient = ccontext.createLinearGradient(cwidth+cwidthoffset,0,cwidthoffset,0);		
-				var cmap = options.getfieldvalue('colormap','jet');
-				var colorbar = colorbars[cmap];
-				for (var i=0; i < colorbar.length; i++) {
-					color = colorbar[colorbar.length-i-1];
-					color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];	
-					cgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
-				}
-				ccontext.fillStyle=cgradient;
-				ccontext.fillRect(cwidthoffset,cheightoffset,cwidth,cheight);
-				
-				//Draw colorbar border
-				ccontext.beginPath();
-				ccontext.lineWidth='1';
-				ccontext.strokeStyle=options.getfieldvalue('colorbarfontcolor','black');
-				ccontext.rect(cwidthoffset,cheightoffset,cwidth,cheight);
-				ccontext.stroke();
-				
+					ccontext.textAlign=textAlign;
+					ccontext.textBaseline='top';
+					ccontext.fillText(labels[i],h,y+cheightoffset*(g+0.5));					
+					ccontext.beginPath();
+					ccontext.moveTo(0,y+cheightoffset*f);
+					ccontext.lineTo(x,y+cheightoffset*f);
+					ccontext.moveTo(cwidth-x,y+cheightoffset*f);
+					ccontext.lineTo(cwidth,y+cheightoffset*f);
+					ccontext.stroke();
+				}
+			}
+			else {
 				for (var i=0; i <= cdivisions; i++) {
 					y = 0.2*cheight;
 					x = i/cdivisions*cwidth;
+					ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
+					ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
+					ccontext.textAlign=textAlign;
+					ccontext.fillText(labels[cdivisions-i],x+cwidthoffset,cheight+cheightoffset*2);
 					ccontext.beginPath();
 					ccontext.moveTo(x+cwidthoffset,cheightoffset);
@@ -127,16 +130,12 @@
 					ccontext.lineTo(x+cwidthoffset,cheight+cheightoffset);
 					ccontext.stroke();
-					ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
-					ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
-					ccontext.textAlign='center';
-					ccontext.fillText(labels[cdivisions-i],x+cwidthoffset,cheight+cheightoffset*2);
-				}
-				if (options.exist('colorbartitle')) {
-					ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
-					ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
-					ccontext.textAlign='center';
-					ccontext.textBaseline='bottom';
-					ccontext.fillText(options.getfieldvalue('colorbartitle'),cwidth/2+cwidthoffset,cheightoffset);
-				}
+				}
+			}
+			if (options.exist('colorbartitle')) {
+				ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif';
+				ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black');
+				ccontext.textAlign='left';
+				ccontext.textBaseline='bottom';
+				ccontext.fillText(options.getfieldvalue('colorbartitle'),c,cheightoffset);
 			} //}}}
 			//}}}
Index: /issm/trunk-jpl/src/m/plot/plotdoc.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plotdoc.js	(revision 20789)
+++ /issm/trunk-jpl/src/m/plot/plotdoc.js	(revision 20790)
@@ -24,4 +24,5 @@
 	console.log('       "colorbarprecision": colorbar label digit precision (default 3, ex: 1, 4)');	
 	console.log('       "colorbarorientation": oreintation of colorbar (default "vertical", ex: "horizontal")');
+	console.log('       "colorbarinnerlabels": choose whether labels are inside colorbar (default "off", ex: "on", "off")');
 	console.log('       "colorbarfontsize": specify colorbar font size (default 1, ex: 14, 22)');
 	console.log('       "colorbarfontcolor": specify colorbar font color (default "black", ex: "green","blue")');
Index: /issm/trunk-jpl/src/m/plot/webgl.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/webgl.js	(revision 20789)
+++ /issm/trunk-jpl/src/m/plot/webgl.js	(revision 20790)
@@ -335,6 +335,12 @@
 		var deltaY = (canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight / canvas.zoom * -2 * canvas.controlsensitivity;
 		
-		canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(canvas.rotation[0])) * deltaY;
-		canvas.translation[1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(canvas.rotation[0])) * deltaY;
+		if (canvas.twod) {
+			canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(0)) * deltaY;
+			canvas.translation[1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(0)) * deltaY;
+		}
+		else {
+			canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(canvas.rotation[0])) * deltaY;
+			canvas.translation[1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(canvas.rotation[0])) * deltaY;
+		}
 	}
 	else {
