File Exchange

image thumbnail


version 1.0.2 (61.9 KB) by Jackson Burns
Writes the values of bars in bar graphs, with options to rotate text, change how text is displayed, and ignore bars with a value of zero.

1 Download

Updated 22 Jul 2019

GitHub view license on GitHub

Adds the value of the bar on top of the bar for the active figure, ignoring
bars with a value of zero. Automatically pulls bar height data from the
figure. Accepts up to three variable arguments in any order:
rotation is the angle of the text (default zero)
textoption is the formatspec string (default '%.0f')
ignorezero is a logical indicating if bars with a value of zero are
labeled (default true)

Example usage:
bar([2 6 7])
h = barlabel
h =
Figure (1) with properties:

bar([3 98 65])
Labels all bars (including zeros) and rotates text 45 degrees

Cite As

Jackson Burns (2019). barlabel (, GitHub. Retrieved .

This function abstracted from this answer on MATLAB Answers:

Comments and Ratings (0)



Fixed title unintentionally changed in last version


Added link to GitHub repository.

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