View License

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

» Watch video

Highlights from
Align axes labels in 3D plot

4.8 | 5 ratings Rate this file 39 Downloads (last 30 days) File Size: 2.21 KB File ID: #27450 Version: 1.3
image thumbnail

Align axes labels in 3D plot



02 May 2010 (Updated )

Align the x, y and z labels of the current axes with the x, y and z axes for 3D plots.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

If the current axes have been rotated away from the X-Y view, this function will calculate the angles of the current x, y and z axes with respect to horizontal. These angles are used to rotate the current x, y and z axes labels to align them with their respective directions.

This only works for equal sized axes (axis equal) and orthographic projection.


This file inspired Tools For Axis Label Alignment In 3 D Plot.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
03 Oct 2016 Changjie Guan

Very useful function!

22 Feb 2016 Matthew Arthington


"Tools For Axis Label Alignment In 3 D Plot" was inspired by this function. Please look at that submission to see if it can do what you need.

Comment only
18 Feb 2016 jasongrig

Hi, this does work with "axis equal" on. Any idea on how to make it work with the z axis set to automatic?

Comment only
19 Jun 2015 George Shoane

Fantastic program. It works!

Comment only
24 Oct 2014 Maria

Maria (view profile)

30 Apr 2012 alex harijanto

23 Jun 2011 Mehdi Moghaddam

that was perfect...just has a typing mistake.... instead of axis equal you have written axes equal....thnx

14 Jun 2011 Matthew Arthington


Yes, it does, and I've updated it so that it also works with Camera Roll too. Hope this helps.

Comment only
14 Jun 2011 Jveer

Jveer (view profile)

does this work if you rotate using orbit camera from cameratoolbar?

Comment only
19 May 2010 Matthew Arthington

From the author: The labels should appear in the same place for the same view, but Matlab decides where that place is according to the current spacing.

I've looked into making this work without "axis equal" having been called (equal sized axes) and I'm stumped as to how to figure out the stretch of the plotted axes when they're not equal. Any help would be appreciated.

Comment only
17 May 2010 Rob Campbell

Rob Campbell (view profile)

Useful. The only problem is that if you rotate and re-align a few times then it's possible for the labels to drift away from the centre of the axes. It would be nice if the label were re-centred as well as aligned.

17 May 2010 1.1

Added the conditions under which the function correctly works.

14 Jun 2011 1.2

Updated to allow Camera Roll to be used and still work out the angles correctly, i.e. allow a change in CameraUpVector axes property. The z axis label will now be rotated too, to align it with its axis direction if the camera has been rolled.

30 Jan 2012 1.3

Fixed typos in help and warning. Updated help with examples including its use as a callback after each rotate3d event.

Contact us