title: Matlab colorbar with two axes
body: <p>I'm using the mapping toolbox to create a contour plot with <code>contourfm()</code> <code>contourcbar()</code> and <code>caxis()</code> to label the colorbar. What is the best way to add a second axis to the colorbar so that it looks something like this?</p>
  
  <p><a href="https://i.stack.imgur.com/gUx8M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUx8M.png" alt="A mock up of a two-axis colorbar"></a></p>
  
  <p>If it makes a difference, I'm running Matlab v2014b on RHEL6 with -nodesktop and -nodisplay. Thanks in advance!</p>
  
  <p>Edit 1: I used Benoit_11's answer to come up with some example code to reproduce the problem. Wait for the plot to be created, then re-size the figure window. You'll see that the second colorbar axis (left side) doesn't scale properly with the rest of the plot. Any advice to fix this would greatly appreciated! </p>
  
  <pre><code>figure('Color','white')
  worldmap('north america')
  load topo
  R = georasterref('RasterSize',[180 360], 'Latlim',[0 80],'Lonlim',[-160 -50]);
  
  contourfm(topo, R, -7000:1000:3000)
  caxis([-8000 4000])
  
  
  hBar1 = contourcbar
  contourcmap('jet')
  caxis([1 10])
  BarPos = get(hBar1,'position');
  ylabel(hBar1,'Total electron content','FontSize',12);
  haxes = axes('position',BarPos,'color','none','ytick',0:5:15,'ylim',[0 
  15],'xtick',[]);
  ylabel('Approximate position error','FontSize',12)
  </code></pre>