Code covered by the BSD License  

Highlights from
axescenter

5.0

5.0 | 2 ratings Rate this file 82 Downloads (last 30 days) File Size: 4.26 KB File ID: #22956
image thumbnail

axescenter

by Matt Fig

 

11 Feb 2009 (Updated 19 Feb 2009)

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

| Watch this File

File Information
Description

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.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
PlotAxisAtOrigin
This submission has inspired the following:
oaxes

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Relies on undocumented properties.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
13 Feb 2009 Matt Fig

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

16 Feb 2009 Thomas Jatzkowski

That works very well!

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

19 Feb 2009 Sergei Vonsovskii

That works very good!

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

19 Feb 2009 Matt Fig

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.

19 Feb 2009 Sergei Vonsovskii

AXESCENTER is doing what it is supposed to do.

22 Jan 2010 Stefan

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)

08 Apr 2010 Petter

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

13 May 2011 Robert

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.

13 May 2011 Matt Fig

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:

subplot(1,2,1)
plot(-10:10) % Origin-centered data
axescenter
xlabel('X Label') % Correctly placed!
subplot(1,2,2)
plot(-pi:.1:pi,cos(-pi:.1:pi))
axescenter
xlabel('X Label2') % Correctly placed.

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

08 Nov 2011 J

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

Please login to add a comment or rating.
Updates
16 Feb 2009

Input checking to insure axes handle is passed.

19 Feb 2009

Fixed problem of non-figure parents.

Tag Activity for this File
Tag Applied By Date/Time
axis Matt Fig 12 Feb 2009 14:09:46
axes Matt Fig 12 Feb 2009 14:09:46
center Matt Fig 12 Feb 2009 14:09:46
central Matt Fig 12 Feb 2009 14:09:46
origin Matt Fig 12 Feb 2009 14:09:46
zoom Matt Fig 20 Feb 2009 13:01:33
pan Matt Fig 20 Feb 2009 13:01:33
plot Matt Fig 20 Feb 2009 13:01:33
axes yar gab 25 May 2009 14:43:43

Contact us at files@mathworks.com