File Exchange

## Align axes labels in 3D plot

version 1.3 (2.21 KB) by

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

4.83333
6 Ratings

Updated

Editor's Note: This file was selected as MATLAB Central Pick of the Week

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.

hyprfrco

### hyprfrco (view profile)

Do not work. Fails when axis not equal.

Prefect. Thanks!

Changjie Guan

### Changjie Guan (view profile)

Very useful function!

Matthew Arthington

### Matthew Arthington (view profile)

@jasongrig

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

jasongrig

### jasongrig (view profile)

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

George Shoane

### George Shoane (view profile)

Fantastic program. It works!

Maria

alex harijanto

### alex harijanto (view profile)

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

Matthew Arthington

### Matthew Arthington (view profile)

@Jveer

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

Jveer

### Jveer (view profile)

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

Matthew Arthington

### Matthew Arthington (view profile)

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.

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.