
How to set colorbar tick labels between ticks
    15 views (last 30 days)
  
       Show older comments
    
    Fabrice Lambert
 on 9 Aug 2019
  
    
    
    
    
    Edited: Fabrice Lambert
 on 9 Aug 2019
            Hi all,
The default setup for Matlab colorbar is to set the tick label just next to the tick (below, above, right of, left of). How do I set the label between two ticks? In the following example, I want 'Decrease', 'Slight Decrease', 'Slight Increase', and 'Increase' between the ticks, while 'No Change' stays below the tick:
Thanks!

0 Comments
Accepted Answer
  Neuropragmatist
      
 on 9 Aug 2019
        Does it matter if the ticks are moved as well?
figure('Position',[200 200 1000 200])
plot(0,0)
cc = colorbar('Location','SouthOutside');
cc.YTick = [0.125 0.375 0.5 0.625 0.875];
cc.YTickLabel = {'Decrease', 'Slight Decrease', 'No Change', 'Slight Increase', 'Increase'};
gives:

Otherwise you could remove the colorbar labels, and use 'text' with the units normalized and position new labels yourself, then they would be relative to the plot, not the colorbar which wouldn't be a perfect solution but might help you this once:
Hope this helps,
M.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
