File Exchange

image thumbnail

Axis_Prunelabels -- clean up redundant axis labels

version 1.0.0.1 (2.27 KB) by Gautam Vallabha
Minimizes redundant axis labels in a grid of subplots

1 Download

Updated 01 Sep 2016

View License

Editor's Note: This was a File Exchange Pick of the Week

AXIS_PRUNELABELS takes a figure with a grid of subplots (created using either SUBPLOT or custom AXES commands), and (a) forces all the subplots to have the same axis limits, and (b) turns off axis labels on all the "interior" subplots, thereby reducing the visual clutter.
By default, it operates on both the x- and y-axes, and on the current figure.

This function works with MATLAB 6.5 (R13). Additionally, if LINKAXES is available (MATLAB 7.0), then all the subplot axes linked together.

Comments and Ratings (4)

Andrew Stevens

I use and like this piece of code quite a bit.

I did however just notice that if you have changed the location of the axis, this won't prune the correct labels. For instance, I had set my x-axis to 'top' on a 3 X 2 subplot matrix and axis_prunelabels left the labels on the bottom 2 sub-plots.

Probably a simple fix the author might consider...

Wolfgang Schwanghart

Worked excellent for my needs, features a good help and comments, and has error checking. Hence, I rate it excellent.

One thing: I made various subplots and applied axis_prunelabels to the y-axes.

When each subplot features an axis label on the y-axis (e.g. ylabel('depth')), than these labels won't be removed.

Gautam Vallabha

Regarding using
findobj(...,'-not','tag','legend)
I wrote this function for R13, which didn't support logical operators with FINDOBJ. Also, there may be other kinds of special axes other than legends.

A general solution would be to have a optional parameter where the user can directly specify the list of axes handles. Feel free to extend this function in this manner and submit as a new FileExchange posting.

Mathias Ortner

This is useful,

but it does not handle legends properly.
Consider replacing the line 45 by the following to improve it.

% find the axes in the figure
h=findobj(figHandle,'type','axes','-not','Tag','legend');

Updates

1.0.0.1

Updated license

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor