Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created November 26, 2018 01:13
Show Gist options
  • Save mattgaidica/78f2b6aa0fd0ba92616fe2a1ce2e3da7 to your computer and use it in GitHub Desktop.
Save mattgaidica/78f2b6aa0fd0ba92616fe2a1ce2e3da7 to your computer and use it in GitHub Desktop.
function cb = cbAside(ax,labelText,cbColor,caxisVals)
cbOffset = .001;
cb = colorbar(ax,'Location','east');
% % cb.FontSize = 8;
gcaPos = ax.Position;
cbPos = cb.Position;
set(cb,'position',[gcaPos(1) + gcaPos(3) + cbOffset gcaPos(2) cbPos(3)/2 gcaPos(4)]);
set(cb,'YAxisLocation','right');
cb.Color = 'r';
if exist('labelText')
cb.Label.String = labelText;
end
if exist('cbColor')
cb.Color = cbColor;
else
cb.Color = 'r';
end
if exist('caxisVals')
caxis(ax,caxisVals);
else
if sum(abs(caxis)) > 10
caxis(ax,round(caxis));
end
end
cb.Ticks = caxis;
cb.Box = 'off';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment