View License

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

» Watch video

Highlights from

5.0 | 4 ratings Rate this file 31 Downloads (last 30 days) File Size: 4.26 KB File ID: #22956 Version: 1.2
image thumbnail



Loginatorist (view profile)


11 Feb 2009 (Updated )

Puts axes in the center of a plot. Zooming, panning and some command line manipulations allowed.

| Watch this File

File Information

AXESCENTER(AX) puts axes in the center of axes AX. If AX is not specified, the current axes will be used. Many commonly used command line options are available to manipulate the center axes, as well as zoom and pan from the figure's menubar. See the help for a fuller description of features, and a demo.

This function relies on undocumented and unsupported properties, so it may not work on some versions of Matlab.

Tested on 2007a 2007b and 2006a.

Please email me about bugs and other concerns, and email me if this doesn't work on your version of Matlab. Thanks.


Plot Axis At Origin inspired this file.

This file inspired Oaxes Central Axis Lines Through An Origin.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Relies on undocumented properties.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
25 Jun 2014 Robert

Robert (view profile)

Works great! NB. seems to be incompatible with new graphics in the 2014b release, hope you can modify it to sense the matlab release and operate accordingly.

06 Apr 2013 Heather Moreland

This is great! Just once question. Is there a way to keep the "box" around the figure so as to sort of frame it? Here is my code

function z=graph(x)

Any suggestions would be greatly appreciated. Thanks.

Comment only
16 Feb 2013 Mircea

Mircea (view profile)

Does this work on 3d-plots?

Comment only
26 Jan 2013 Wyatt

Wyatt (view profile)

I couldn't get it to work on Matlab R2011B, but I am a beginner.

Comment only
04 May 2012 Joachim

08 Nov 2011 bullox

bullox (view profile)

This is great - using on 2010a. Doesn't seem to put scale units (e.g. 10^-14) unless I run it twice... any ideas?

Comment only
13 May 2011 Loginatorist

Loginatorist (view profile)

Hello Robert,

There is no guarantee the axes go through the origin with any plot. This will depend on the data. But if the data is so centered, axescenter will go through the origin. Also, I cannot reproduce your claim about the xlabel. For example:

plot(-10:10) % Origin-centered data
xlabel('X Label') % Correctly placed!
xlabel('X Label2') % Correctly placed.

Please email me if with some code to reproduce what you are seeing...

Comment only
13 May 2011 Robert

Robert (view profile)

Great idea, two bugs for somebody to fix though:

1) It doesn't seem to work correctly with subplots (i.e. axes don't actually go through the origin)

2) It seems to change the focus from the current axes somehow, so that e.g. calls to xlabel don't work after calling axescenter. However, this is fixed by reselecting the axes.

Comment only
08 Apr 2010 Petter

Petter (view profile)

A better functionality would be to always have the axes intersect at the origin.

Comment only
22 Jan 2010 Stefan

Stefan (view profile)

This is very good; I have always wondered why MatLab does not have this feature as a standard.

I have one problem: only the "hidden" axes will show (in gray) when printing to a file (TIFF)

19 Feb 2009 Sergei Vonsovskii

AXESCENTER is doing what it is supposed to do.

Comment only
19 Feb 2009 Loginatorist

Loginatorist (view profile)

Sergei noticed that if the parent of the current axes is not a figure, AXESCENTER will not position correctly. He had called AXESCENTER for an axes that was in a uipanel. An update is on the way.

Comment only
19 Feb 2009 Sergei Vonsovskii

That works very good!

2 Matt Fig
This is a good work. Great for other user from Russia

Comment only
16 Feb 2009 Thomas Feja

That works very well!

One remark:
gives wrong tick labels when used together with "axis equal"

13 Feb 2009 Loginatorist

Loginatorist (view profile)

I realized I should have a check that the input arg is a handle of the correct type. Update on the way.

Comment only
16 Feb 2009 1.1

Input checking to insure axes handle is passed.

19 Feb 2009 1.2

Fixed problem of non-figure parents.

Contact us