## How to rotate XtickLabels and make them vertical.

Asked by dipak sanap

### dipak sanap (view profile)

on 29 Dec 2015
Latest activity Commented on by Walter Roberson

### Walter Roberson (view profile)

on 19 Oct 2018
Accepted Answer by Walter Roberson

### Walter Roberson (view profile)

f = fopen('1IV7_1M.txt','r');
x = fscanf(f , '%d %d %f' , [3 inf]);
x = x';
g = fopen('1FA3_6_1M.txt','r');
y = fscanf(g, '%d %d %f %f',[4 inf]);
y = y';
h = fopen('1FA3_12_1M.txt','r');
z = fscanf(h, '%d %d %f %f', [4 inf]);
z = z';
F = [x(:,3), y(:,3), z(:,3)];
Fmean = mean(F,2);
Fsd = std(F,0,2);
Ferr = Fsd/sqrt(3);
errorbar(Fmean, Ferr, 'bx');
xlabel ('H-bonded amide residue pairs ');
ylabel ('F (pN)');
label = cellstr(num2str(x(:,1:2)));
title('Average force on backbone atoms due to all atoms of its parntering H-bond residue ');
set(gca,'XTickLabel',label);
set(gca,'XTick',1:length(label))

### Walter Roberson (view profile)

Answer by Walter Roberson

### Walter Roberson (view profile)

on 29 Dec 2015

The method of rotating tick labels depends upon which MATLAB you are using. If you are using R2014b or later then see http://www.mathworks.com/help/matlab/ref/axes-properties.html#property_xticklabelrotation

on 29 Dec 2015

dipak sanap

### dipak sanap (view profile)

on 29 Dec 2015
yes, something like that i did and it worked :)

### Ahmed Lachhab (view profile)

Answer by Ahmed Lachhab

### Ahmed Lachhab (view profile)

on 18 Aug 2018

my x axis labels are long (dates), I have a 2013a version, how can I tilt them by 45 deg. thank you

Walter Roberson

### Walter Roberson (view profile)

on 22 Aug 2018
The File Exchange Contribution linked to above should work for you.

### Mariana Frid Dalarsson (view profile)

on 16 Oct 2018

Try this: xtickangle(45)

Walter Roberson

### Walter Roberson (view profile)

on 19 Oct 2018
This will work from R2016b onwards, but would not have worked for Ahmed Lachhab's R2013a version.