Code covered by the BSD License  

Highlights from
tick2text: create easy-to-customize tick labels


4.2 | 5 ratings Rate this file 70 Downloads (last 30 days) File Size: 5.89 KB File ID: #16003
image thumbnail

tick2text: create easy-to-customize tick labels



20 Aug 2007 (Updated )

Customized tick marks, maintained on zoom and pan

| Watch this File

File Information

This function allows for more versatile labeling of axis ticks. It offers two possible modifications: 1) automatic reformatting of tick labels based on a user-supplied format or function, and 2) conversion of tick labels to text objects.
The first option simply offers a shortcut to manual reformatting via the [X/Y/Z]TickLabel properties of axes. It also overrides the zoom/pan function of the axis so that ticks will update with your specified formatting as you zoom and pan.
With the second option, the original tick labels are removed, and new text objects are created that mimic x, y, and/or z tick labels. The text object format allows more modification (such as color, rotation, etc) than the original tick labels, and also allows TeX strings to be utilized in tick labels.
Update on 3/26/2013 includes changes to input syntax (no longer need to manually specify axis offsets, and adds convert-or-not option), as well as improved function.


Format Tick Labels and Parse Pv Pairs inspired this file.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Requires R2007a+ for zoom and pan
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
23 Nov 2012 Liad Mudrik

I've been trying to use this function to replace the ticks with letter strings (e.g., 'frontal', 'temporal', etc.) that are stored in cell array. I get an error message saying that the function does not accept cell as input. How can I solve the problem?

03 Mar 2011 Geoffrey

Great program. Thank you. I particularly like the option to use sprintf formatting.

I would appreciate being able to adjust the offset in orthogonal planes. By this I mean being able to apply an x-offset to the y-labels or a z-offset to the x-labels.

01 Sep 2010 Kelly Kearney

C Berry,

I'm not quite sure what you mean when you say it doesn't parse a minus sign; can you give a small example?

26 Aug 2010 C Berry

I'd like to use this to label the axes using the LaTeX interpreter, however it appears to be impossible to successfully parse a minus sign, which is rather annoying. Does anyone have any ideas?

06 Jan 2010 Narasinha Parasnis  
01 Oct 2007 Frank Hart

I like this function's potential, but I'm not presently able to use it well. I'm working with x-axis limits that are multiples of pi, and I'd like to label the axis as such. It is unclear how to do this. Your example simply appends a pi. I'd like to specify the XTicks at pi-based intervals (possibly fractional), then use tick2text to place labels with pi in the tick marks.

For example, consider a uniform probability density function for a radian angle. It is distributed (x-axis) between [-pi,pi] and has a value of 1/(2*pi). I'd like to tick the x-axis at, say, pi/4 intervals, and the y-axis at 1/pi, 1/[2*pi], 1/[4*pi], etc. etc.

04 Sep 2007 Andrew .

When using this function, the tick labels overlap axis labels, so this function is only useful if xlabel or ylabel is not required

23 Aug 2007 Mukhtar Ullah

Sorry, forgot to rate it.

23 Aug 2007 Mukhtar Ullah

Very clever!
If the tick-label position is computed relative to xlabel, ylabel and zlabel, this function can be extended to 3-D figures as well.

02 Mar 2009

Added function handle input option, corrected some bugs, and added new example

04 Jun 2009

Fixed erroneous behavior when axes are logarithmically scaled

30 Jun 2009

Added ability to modify x,y, and z ticks for 3D axes

27 Mar 2013

- no longer need to manually specify axis offsets
- added simple reformat without conversion-to-text option
- more robust handing of non-default configured axes ([XYZ]Dir, [XYZ]Scale, and [XY]AxisLocation properties changed)

27 Mar 2013

Credited parse_pv_pairs as a separate FEX entry

10 Jul 2014

- updated for 2014b graphics

Contact us