Matlab: Bar chart x-axis labels missing -


i'm using following code create bar chart in matlab.

a = [1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9] bar(a) set(gca,'xticklabel',{'one','two','three','four','five','six','seven','eight','nine','zero','one','two','three','four','five','six','seven','eight','nine'}) 

code works fine except x-axis labels don't appear on corresponding position on x-axis. how resolve issue?

enter image description here

when set xticklabel, telling matlab replace text each tick currently new text provide. if run first 2 lines, see matlab default has put xticks on 0:2:20. can resolve issue first telling matlab put ticks each individual bar, , re-labeling these ticks:

a = [1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9] bar(a) set(gca, 'xtick', 1:length(a)) set(gca,'xticklabel',{'one','two','three','four','five','six','seven','eight','nine','zero','one','two','three','four','five','six','seven','eight','nine'}) 

you have pretty cluttered x-axis @ point...you want rotating xticklabels rotatexlabels function fileexchange or built-in functionality on matlab14b , later.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -