File Exchange

image thumbnail

Y-labels alignment in subplots

version 1.1 (3.03 KB) by

Function to align the ylabels within a figure containing multiple subplots



View License

This function takes care of the alignment of ylabels in figures with multiple subplots.
This is done because ylabels are usually not aligned when the yticks labels are of different length in different subplots.
The alignment is performed within each column of subplots and was designed to work with the default MATLAB subplot function as well as with the subplot1 function released on MATLAB central.

Comments and Ratings (4)


Ilyas (view profile)

Thank you so much for this. Having the y axis labels not aligned was driving me crazy. This should be embedded within Matlab's figure creating actually. So important in my opinion.

Another function which should be in the core Matlab functionality! This nice little script does what it claims to do.

As documented by the function description (in the code) resizing the figure after aligning the labels messes up their positioning, but that's no issue provided that this is executed after all resizing operations are complete. Running this function when subfigures have misaligned labels also has the benefit that labels which protrude further from the axes are less likely to get chopped off by the figure renderer during export operations. (Fixing this problem is actually why I'm using it, aside from the need to tidy things up.)


gbernardi (view profile)

I updated the file to solve the bug occurring when legends were added.


returns not only the axes' handles but also the legends' handles, which I didn't know.



I fixed the bug that occurred when legends were added to the subplots.

MATLAB Release
MATLAB 8.0 (R2012b)

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

» Watch video