Index: /issm/trunk-jpl/src/m/plot/applyoptions.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 20651)
+++ /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 20652)
@@ -14,17 +14,14 @@
 				data = data[0];
 			} //}}}
-			//Variable options initialization {{{		
+			//Variable options initialization {{{
 			var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			var canvassize = options.getfieldvalue('canvassize',480);
-			var cheight;
-			var cwidth;
-			var cdivisions = cheight/4;
-			var color;
-			var ccontext,ccanvas,ccanvasid,ccanvashtml;
+
+			var ccontext,ccanvas,ccanvasid,ccanvashtml,cheight,cwidth,color,y,x;
 			var colorbarorientiation = options.getfieldvalue('colorbarorientation','vertical');
 			var cheightoffset = options.getfieldvalue('colorbarfontsize',18);
 			var cwidthoffset = options.getfieldvalue('colorbarfontsize',18)*3;
-			var y;
-			var x;
+			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])
 			//}}}
 			//Set colorbar lables {{{
@@ -33,5 +30,5 @@
 			var caxisdelta = caxis[1] - caxis[0];
 			var clabelitem;
-			var precision=options.getfieldvalue('colorbarprecision',3);
+			var precision = options.getfieldvalue('colorbarprecision',3);
 			
 			if (options.getfieldvalue('log','off')!='off') {
@@ -47,36 +44,14 @@
 			//Handle orientation {{{
 			if (colorbarorientiation=='vertical') { //{{{
-				cheight = options.getfieldvalue('colorbarheight',0.95)*canvassize;
-				cwidth = options.getfieldvalue('colorbarwidth',canvassize/20);
 				ccanvasid = options.getfieldvalue('colorbarcanvasid',options.getfieldvalue('canvasid')+'_colorbar');
 				ccanvashtml = document.getElementById(ccanvasid);
-				if (ccanvashtml==null) {
-					ccanvas = $('<canvas id="'+ccanvasid+'" width="'+String(cwidth+cheightoffset*4)+'" height="'+String(cheight+cheightoffset*2)+'"></canvas>').insertAfter('#'+options.getfieldvalue('canvasid'));
-					ccanvas.css({'position':'relative','top':((canvassize-cheight-cheightoffset)/-2).toFixed(2)+'px'});
-					ccontext = ccanvas[0].getContext('2d');
-				}
-				else{
-					ccanvas = $('#'+ccanvasid);
-					if (options.exist('colorbarcanvasid')&&!ccanvashtml.hasOwnProperty('init')){
-						//store actual colobar size
-						cwidth = ccanvashtml.clientWidth;
-						cheight = ccanvashtml.clientHeight;
-						ccanvas.attr({width:cwidth+cheightoffset*4,height:cheight+cheightoffset*2}).css({width:cwidth+cheightoffset*4,height:cheight+cheightoffset*2});
-						//get html object instead of jqurey object to modify height/width to accomodate labels
-						ccanvashtml.cwidth = cwidth;
-						ccanvashtml.cheight = cheight;
-						ccanvashtml.init = true;
-					}
-					else {
-						cwidth = ccanvashtml.cwidth;
-						cheight = ccanvashtml.cheight;
-					}
-					ccontext = ccanvas[0].getContext('2d');
-					/*erase existing colorbar:*/
-					ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height);
-					ccontext.beginPath();
-				}
+				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('cmap','jet');
 				var colorbar = colorbars[cmap];
@@ -123,33 +98,13 @@
 				ccanvasid = options.getfieldvalue('colorbarcanvasid',options.getfieldvalue('canvasid')+'_colorbar');
 				ccanvashtml = document.getElementById(ccanvasid);
-				if (ccanvashtml==null) {
-					ccanvas = $('<canvas id="'+ccanvasid+'" width="'+String(cwidth+cheightoffset*4)+'" height="'+String(cheight+cheightoffset*5/2)+'"></canvas>').insertAfter('#'+options.getfieldvalue('canvasid'));
-					ccanvas.css({'position':'relative','top':((canvassize-cheight-cheightoffset*2)/-2).toFixed(2)+'px'});
-					ccontext = ccanvas[0].getContext('2d');
-				}
-				else{
-					ccanvas = $('#'+ccanvasid);
-					if (options.exist('colorbarcanvasid')&&!ccanvashtml.hasOwnProperty('init')){
-						//store actual colobar size
-						cwidth = ccanvashtml.clientWidth;
-						cheight = ccanvashtml.clientHeight;
-						//get html object instead of jqurey object to modify height/width to accomodate labels
-						ccanvashtml.width = cwidth+cheightoffset*6;
-						ccanvashtml.height = cheight+cheightoffset*5/2;
-						ccanvashtml.cwidth = cwidth;
-						ccanvashtml.cheight = cheight;
-						ccanvashtml.init = true;
-					}
-					else {
-						cwidth = ccanvashtml.cwidth;
-						cheight = ccanvashtml.cheight;
-					}
-					ccontext = ccanvas[0].getContext('2d');
-					/*erase existing colorbar:*/
-					ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height);
-					ccontext.beginPath();
-				}
-				var cgradient = ccontext.createLinearGradient(cwidth+cwidthoffset,0,cwidthoffset,0);
-				
+				
+				ccanvas = $('#'+ccanvasid);
+				cwidth = ccanvashtml.clientWidth;
+				cheight = ccanvashtml.clientHeight;	
+				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('cmap','jet');
 				var colorbar = colorbars[cmap];
