This function makes pointed ends for colorbars to indicated that values have been clipped.
Chad Greene (2021). cbarrow: pointy ends for colorbars (https://www.mathworks.com/matlabcentral/fileexchange/52515-cbarrow-pointy-ends-for-colorbars), MATLAB Central File Exchange. Retrieved .
Works great. A made one small modification for aesthetics:
cb.Box = 'off' (line 195) removes the box around the original colourbar, but the line along the main colourbar axis remains. The newly created outline is aligned below this axis line and therefore results in a thicker edge (2x the original line width). This issue can easily be fixed by shifting the outline and stretching the colourbar upwards* by the line width. The stretching is necessary, since the shift is creating a small line of white space which needs to be filled. I added the following lines of code after line 244 (axis([0 1 0 1])) to implement this fix:
set(gca,'Units','points'); % change new outline units to points
cbpos = get(gca,'Position'); % get outline position
set(gca,'Position',[cbpos(1),cbpos(2)+linewidth,cbpos(3),cbpos(4)]) % shift outline position upwards by the linewidth
set(cb,'Units','points'); % change colour bar units to points
cb.Position(4) = cb.Position(4)+linewidth; % stretch colourbar vertically upwards by the linewidth
*for horizontal colour bars with a bottom-aligned axis, fix would have to be implemented for every case (i.e. left/right/up/bottom-aligned colourbar axes)
How to use it in sublot? I tried but the cbarrow only work for the last plot
I have a problem using this function. After I use it the color bar get extremely thick and locates far away from my figure. Here is the link of my question:
does the trick!
A minor fix that I've used to maintain the "figure('visibility', 'off')" setting -- change line 252 "axes(h)" to "set(gcf, 'CurrentAxes', h)", and similar for line 255. Otherwise, an invisible figure becomes visible when you call this function.
thanks so much
Thanks Chad, works fine!
Ah, good catch Aodat! Thanks for pointing this out. The bug should be fixed now.
I'm experiencing a bug with cbarrow('down').
figure; colorbar; cbarrow('down');
Doesn't work properly for me, but shows additional lines. Would be great if you could fix that. Tested with Matlab 2015a & 2015b.
Thank you so much!
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!