image thumbnail


version (4.44 KB) by Marc Jakobi
Converts axis tick labels and contour line labels to percentages


Updated 05 Oct 2016

View License

PERCENTLABEL: Converts axis tick labels and contour line labels to percentages

percentlabel(h); Attempts to add a % symbol to all all
tick labels of the handle h

percentlabel(h, OptionName, OptionValue); With additional

clab = percentlabel(h); Return labels of
contour lines

Input arguments:

h: Figure or Axes handle.
It is recommended
to call this
function on an axes

Option-Value pairs

OptionName: OptionValue: Explanation:

'X' 'none' - Ignore x axis ticks
'normalized' - Convert from [0,1]-normalized XTickLabels
'absolute' (default) - add symbol without conversion

'Y' 'none' - Ignore y axis ticks
'normalized' - Convert from [0,1]-normalized YTickLabels
'absolute' (default) - add symbol without conversion

'C' 'none' - Ignore colorbar ticks
'normalized' - Convert from [0,1]-normalized colorbar TickLabels
'absolute' (default) - add symbol without conversion


percentlabel(gca, 'X', 'normalized', 'C', 'absolute')
--> converts normalizeden XTickLabels to percentages and adds a
percent symbol to the colorbar TickLabels

Option-Value pairs for contour line labels:

OptionName: OptionValue: Explanation:

'L' 'autoline' (default) - automatically add contour line labels
[xl, yl] - adds contour line labels to the coordinates at [xl, yl]
xl and yl are vectors containing
the X- and Y-coordinates of
the labels and must be combined into a

'LMode' 'normalized' - converts normalized labels into percentages
'absolute' (default) - adds percentage symbols without conversion

'LAngle' 'default' (default) - add the labels centered from top left to bottom right
alpha - add the labels according to the
nearest points of a square cross section
with the angle alpha (starting from the


clab = percentlabel(gca, 'L', 'autoline', 'LMode', 'absolute');
--> Automatic generation of contour line labels absolute

percentlabel(gca, 'L', [(x1; x2; x3), (y1; y2; y3)], 'LMode', 'normalized');
--> generates the labels at the coordinates set by
[xl,yl], where xl = [x1;x2;x3] and yl = [y1;y2;y3]
The data that is normalized to [0, 1] are converted into

percentlabel(gca, 'L', 'autoline', 'LAngle', -45)
--> Sets the labeling at an angle of approx. -45°.

Output argument:

clab: (optional) Cell-Array containing the text
objects of the contour line labels

Percentlabel-Contour line labels can be found by typing:

Author: Marc Jakobi - 18.06.2015

Cite As

Marc Jakobi (2021). percentlabel (, MATLAB Central File Exchange. Retrieved .

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

Inspired by: C2xyz contour matrix to coordinates

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!