Code covered by the BSD License  

Highlights from
ticklabelformat - set a dynamic format of axes tick labels

5.0 | 3 ratings Rate this file 60 Downloads (last 30 days) File Size: 5.21 KB File ID: #36254 Version: 1.4
image thumbnail

ticklabelformat - set a dynamic format of axes tick labels


Yair Altman (view profile)


18 Apr 2012 (Updated )

ticklabelformat sets the axes tick labels format. The format is preserved during zoom/pan/maximize

| Watch this File

File Information

ticklabelformat sets the format of an axes tick labels based on sprintf format specifiers. The format is preserved during zoom/pan/maximize and applied to the dynamic tick values.
Calling ticklabelformat with an empty ([] or '') format will revert to Matlab's normal tick labels display behavior.
     ticklabelformat(hAxes, axName, format)
Input Parameters:
     hAxes - handle to the modified axes, such as returned by the gca function
     axName - name(s) of axles to modify: 'x','y','z' or combination (e.g. 'xy')
     format - format of the tick labels in sprintf format (e.g. '%.1f V') or a
                 function handle that will be called whenever labels need to be updated
     ticklabelformat(gca,'y','%.6g V') - sets y axis in current axes to display 6 significant digits
     ticklabelformat(gca,'xy','%.2f') - sets x & y axes in current axes to display 2 decimal digits
     ticklabelformat(gca,'z',@myFcn) - sets a function to update the Z tick labels in current axes
     ticklabelformat(gca,'z',{@myFcn,extraData}) - sets an update function as above, with extra data
     This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!
Technical description and more details:
Bugs and suggestions:
     Please send to Yair Altman (altmany at gmail dot com)

MATLAB release MATLAB 7.14 (R2012a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
11 Feb 2015 Christian

Great script. Callback functionality for formatting is also very useful.

11 Jul 2013 Jorge Arcila Zea

Excellent script. It was very useful. Thank you for share it

17 May 2012 Mayi

Mayi (view profile)

Very good, I have use it in my application. Tanks

20 Apr 2012 1.1

Clarified summary & description

02 Oct 2014 1.3

updated for R2014b (HG2)

05 Jan 2015 1.4

fix for R2014b (HG2)

Contact us