File Exchange

image thumbnail

Format Tick Labels (Extended)

version (18.4 KB) by Patrick Toche
Replace Tick Label with LaTeX compatible Objects. Extends file 15986 created by Alexander Hayes.


Updated 29 Mar 2016

View License

Will replace axes tick labels with formatted text objects that can include both Tex and LaTex interpreted strings. Primary example is to add degree symbols to labels. Inputs can be a cell array of strings or a single string to be appended to the end of each of the current labels. Header documentation includes several examples. Labels can also be rotated.
08/19/2007: Created by Alex Hayes
04/20/2009: Minor Update by Patrick Toche
Introduces a distinction between offsets for the horizontal axis offsetx and for the vertical axis offsety. It took 2 minutes to modify the original file, so credit must go to Alexander Hayes. Any errors are mine, of course.

Comments and Ratings (6)

David Doria

The x axis label seems to overlap the x tick labels?


plot(0:pi/4:pi, data,'LineWidth', 3);

format_ticks(gca,{'0', '\pi/4', '\pi/2', '3\pi/4', '\pi'},[],0:pi/4:pi)

ylim([0 1]);
xlabel('My x label')
ylabel('My y label')

fontSize = 20;


Handy, but could use the same font as the axes by default. Currently you have to set this manually.

Very nice. I've wanted a way to do this for a long time.

Two improvements would be nice: (1) Add support for doing only Y ticks. (2) Check for an axis label and reposition it correctly so that it does not overlap with the new tick labels.


Exactly what i was looking for...

However, 2 tiny suggestions:

To be able to use Y-ticks only one should replace 2 strings around #225 with
%find out if we have to use the LaTex interpreter
all_ticks = [tickx ticky];
temp = all_ticks{1};

it's also a bit unexpected that
offsety>0 means 'left' ...



added a comment in the header about offsetx and offsety

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Format Tick Labels

Inspired: Format Tick Labels (Extended v2)