I want to put labels between ticks, otherwise some labels overlap each other.
set(gca,'XTick',[66 98 134 215 266 330 334 388 414 443 ]);
set(gca,'XTickLabel',{'CD', 'CS', 'E' ,'F','H','I','C','IT','M','U'})
Could somebody please help me?
I want to put labels between ticks, otherwise some labels overlap each other.
set(gca,'XTick',[66 98 134 215 266 330 334 388 414 443 ]);
set(gca,'XTickLabel',{'CD', 'CS', 'E' ,'F','H','I','C','IT','M','U'})
Could somebody please help me?
xTICKS = [66 98 134 215 266 330 334 388 414 443 ];
xTICKS = [0 xTICKS]; %// Add the 0 instance
dxT = diff(xTICKS);%// get differences
xT = xTICKS(1:end-1)+dxT/2; %// Make new tick locations midway the old
This way you can create the locations of your tickmarks + ticklabels midway the old instances. I'm not sure whether you can uncouple the two though, try this:
set(gca,'XTick',xT);
set(gca,'XTickLabel',{'CD', 'CS', 'E' ,'F','H','I','C','IT','M','U'})
You can play around with axes properties, especially those in the section tick values and labels, but I can't see a way to uncouple the tick location and it's corresponding label.
I have run into this problem frequently, but there is a very simple solution...simply pad your labels with spaces on the front! Not necessarily all of them...just the ones that need to move. This is a great trick any time you need a minor adjustment in a text annotation (like with 'arrow', 'text', etc.)
Example:
set(gca,'XTickLabel',{'CD', 'CS', 'E' ,'F','H','I',' C','IT','M','U'})
EDIT: I realized this doesn't address the vertical tick problem. For the Y axis, try
set(gca,'YTickLabel',{'CD', 'CS', 'E' ,'F','H','I',['A' char(10) ' C'],'IT','M','U'})
Note that 'A' and 'C' are technically part of the same label, but they appear to be two different labels because of inserting a line feed (char(10)).