File Exchange

image thumbnail

Format Tick Labels (Extended)

version 1.1 (18.4 KB) by

Replace Tick Label with LaTeX compatible Objects. Extends file 15986 created by Alexander Hayes.

11 Downloads

Updated

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 (5)

David Doria

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

data=rand(5);

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;

set(gca,'FontSize',fontSize)

Oliver Woodford

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

Robert Sparr

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.

Igor

Igor (view profile)

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' ...

Updates

1.1

BSD

1.1

added a comment in the header about offsetx and offsety

MATLAB Release
MATLAB 7.7 (R2008b)
Acknowledgements

Inspired by: Format Tick Labels

Inspired: Format Tick Labels (Extended v2)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video