Code covered by the BSD License  

Highlights from
XTICKLABEL_ROTATE90

4.125

4.1 | 8 ratings Rate this file 43 Downloads (last 30 days) File Size: 2.01 KB File ID: #3150
image thumbnail

XTICKLABEL_ROTATE90

by Denis Gilbert

 

17 Mar 2003 (Updated 25 Mar 2003)

Rotate numeric Xtick labels by 90 degrees.

| Watch this File

File Information
Description

When the XTick labels are long numbers that overlap, making them hard to read or distinguish from one another, you may need to use XTICKLABEL_ROTATE90 in order to orient the tick labels vertically rather than horizontally.

Example 1: Set the positions of the XTicks and rotate them.

figure;
plot([1960:2004],randn(45,1));
xlim([1960 2004]);
xticklabel_rotate90([1960:2:2004]);
%Set "Property-value" pairs
xticklabel_rotate90([1960:2:2004],'Color','m');

Example 2: Rotate XTickLabels at their current position

XTick = get(gca,'XTick');
xticklabel_rotate90(XTick);

Acknowledgements
This submission has inspired the following:
XTICKLABEL_ROTATE
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
22 Mar 2003 Urs Schwarz (us)

very nice utility
a few improvements could include
- adjust fontsize to GCA's current fontsize
- add possibility to change other TEXT props

25 Jul 2003 A. El-Wakeel

You can also change the angle from 90 to 45 for example by changing it in the last row in the program.

24 Jun 2005 Can Ozan Tan

Great utility, one possible improvement to allow strings to be used as labels as well (current version allows only numeric labels):
-allow two input arguments in the preamble:
---XTick (tick positions - numeric - already there)
---XTickLabels (tick labels - could be either numeric or string - new arg)
-comment out line 42 :
xTickLabels = num2str(XTick);
And one glitch:
-When exported, 90 degrees rotated labels appear as if in italics, lower/higher degree rotations (e.g. 89/91) do not solve the issue.

16 Apr 2008 Heiner Körnich

Works nicely with Matlab. Very useful extension. But I had problems to convert the ps-output from matlab to pdf.
So, if you want final pdf-output, I recommend using the routine xticklabel_rotate instead.

07 Jul 2009 Gabriel Akira Schreiber  
26 Apr 2010 Diego Orlando  
05 Nov 2010 Barry  
17 Jun 2011 Thong  
Please login to add a comment or rating.
Updates
25 Mar 2003

1) Fontsize is now set equal to the default axes fontsize.

2) Vectorization of text command

3) Now allows for the specification of text property-value pairs, as suggested by Urs Schwarz.

Tag Activity for this File
Tag Applied By Date/Time
annotation Denis Gilbert 22 Oct 2008 06:58:32
customization Denis Gilbert 22 Oct 2008 06:58:32
xtick Denis Gilbert 22 Oct 2008 06:58:32
xticklabel Denis Gilbert 22 Oct 2008 06:58:32
90 degrees Denis Gilbert 22 Oct 2008 06:58:32
rotate Denis Gilbert 22 Oct 2008 06:58:32
90 degrees WPC 16 Nov 2011 10:44:11
90 degrees Hernando Secr 03 Feb 2012 06:56:00
90 degrees Leo leo 06 Feb 2012 13:40:23

Contact us at files@mathworks.com