Need to set a custom tick label - Bar chart - Numeric values for 'xticklabel' but last tick needs to be alpha characters example - 1,2,3,4,5,6,OAL - How to do
Show older comments
Need to set a custom tick label - Bar chart - Numeric values for 'xticklabel' but last tick needs to be alpha characters example - 1,2,3,4,5,6,OAL - How to do
Answers (1)
set(gca,'xticklabel',[num2str([1:6].'); 'OAL'])
NB: are column vector.
ERRATUM
Account for differing string lengths in concatenation; cell strings work for that purpose--
lbl=[{num2str([1:9].','%.1f')};{'OAL'}];
set(gca,'xticklabel',lbl);
2 Comments
Jerry Vietinghoff
on 4 Aug 2015
Edited: dpb
on 4 Aug 2015
Oh, yeah, the strings aren't same length; use cell strings to handle this...
set(gca,'xticklabel',[{num2str(ty(1:9).','%.1f')};{'OAL'}]);
Categories
Find more on Grid Lines, Tick Values, and Labels in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!