4.66667

4.7 | 3 ratings Rate this file 127 downloads (last 30 days) File Size: 2.75 KB File ID: #13245

TWXTICKLABEL

by Mukhtar Ullah

 

04 Dec 2006 (Updated 16 Jan 2007)

No BSD License  

Tweaks xtick labels for better export to eps for LaTeX inclusion.

Download Now | Watch this File

File Information
Description

TWXTICKLABEL tweaks the xtick labels of the current axis, so that fonts are preserved when the figure is exported to eps (e.g. for inclusion
into LaTeX).

TWXTICKLABEL(AX) applies TWXTICKLABEL to the axis with handle AX.

H = TWXTICKLABEL returns in H the handles of all XTick labels so the user can change every property which is possible with a text object created by text command.
Following are a few examples:

h = twxticklabel;
set(h,'fontsize',12,'fontname','courier'); % to change font name and size
set(h,{'string'},char('10','-3','pi','he','90','ju')); % to change ticklabels
set(h,'rotation',90); % to change angle

The two m-files TWXTICKLABEL and TWYTICKLABEL motivated by the following problems in the way Matlab handles tick labels.
1)
Matlab provides no handles to xtick labels and ytick labels; meaning that you can't change their
properties separately, but only by changing axis properties. For example, the only way to change
the fontname of xtick labels is by setting the fontname property of the axis, thus changing the fontname of all it object, which may not be desirable. If a user wants to rotate the tick labels, one would
like to be able to do that with commands like set(handle, 'rotation', 90); but that is only possible if you have
the handle.

2)
Tick labels do not interpret TeX/LaTeX character sequences; What if you want LaTeX expression $W_i(t)$.

3)
Even if you are happy with changing the properties of the whole axis, another problem arises when the Matlab figure is exported to eps for inclusion into LaTeX. It sometimes changes the fonts (set by the user) of the xticklabels in an unpredictable way (fortunately, this does not happen with xlabel, ylabel, title and other text object).

In these two files, I have tried to create ticklabels by using text command, using a few defaults so that little or no post-processing is required for LaTex users. However, handles are returned for all tick labels, so the user can change every property which is possible with a text object created by text command.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
04 Dec 2006 Mukhtar Ullah

I found a serious problem. Since updating is temporarily unavailable, please remove or comment out the following lines, until I update the file.

set(0, ...
    'defaulttextfontsize', 8, ...
    'defaulttextfontname', 'cmr', ...
    'defaultaxesfontsize', 8, ...
    'defaultaxesfontsize', 8, ...
    'defaultaxesfontname', 'cmr')

31 May 2007 Diego Gruber  
05 Feb 2008 Mukhtar Ullah

This file is no longer needed if you download SETAXES I recently submitted.

05 Feb 2008 a a

Great package, if you add in:
'FontWeight',get(ax,'FontWeight'),
and
'FontName',get(ax,'FontName'),
to the line:
set(h, 'fontsize', get(ax,'fontsize'),..

you can maintain your global font style

20 May 2009 Jon

Very helpful little package. Especially useful with bar(...). Nice work. Thanks.

Please login to add a comment or rating.
Updates
06 Dec 2006

Fixed the problem in case both positive and negative values on the x-axis; and some minor issues.

16 Jan 2007

Removed font defaults.

Tag Activity for this File
Tag Applied By Date/Time
annotation Mukhtar Ullah 22 Oct 2008 08:51:15
customization Mukhtar Ullah 22 Oct 2008 08:51:15
xtick labels Mukhtar Ullah 22 Oct 2008 08:51:15
fonts Mukhtar Ullah 22 Oct 2008 08:51:15
export Mukhtar Ullah 22 Oct 2008 08:51:15
eps Mukhtar Ullah 22 Oct 2008 08:51:15
latex Mukhtar Ullah 22 Oct 2008 08:51:15
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com