Code covered by the BSD License  

Highlights from
oaxes

5.0

5.0 | 2 ratings Rate this file 44 Downloads (last 30 days) File Size: 41.91 KB File ID: #30018
image thumbnail

oaxes

by John Barber

 

13 Jan 2011 (Updated 06 Jun 2011)

Draw central axis lines through an origin point.

| Watch this File

File Information
Description

Oaxes creates a set of axis lines through a specified origin point. Oaxes supports both 2D and 3D views, ticks and tick labels, axis labels, log-scaled axes, and has a plethora of properties, analogous to normal axes properties, that give control over the oaxes object's appearance. In addition, various oaxes-specific properties give the user control over features such as arrows at the axis ends and the extent of the axis lines.

By default, the origin is set at the center of the axes limits, and will remain centered if the parent axes limits change. If a fixed origin point is specified, the axis lines will be drawn using that point as the origin. Additionally, the oaxes object will automatically update in response to changes to many of the parent axes' properties.

See the help text in oaxes.m for more information, including examples.

Oaxes uses a number of undocumented MATLAB features which may cause problems in older versions of MATLAB. If there are workarounds that do not require significant changes, I will add them to the code. MATLAB version 7.10.0 (R2010a) was used to develop and test Oaxes.

Installation: Unpack the contents of the .zip file, then add the top-level folder ("customplots") to the MATLAB path.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
axescenter

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
14 May 2011 Christian

I got an error message when trying 'arrow' 'off', simply by typing in:

>> oaxes('arrow','off')
??? Index exceeds matrix dimensions.

Error in ==> oaxes at 643
        OA = customplots.oaxes(hAx,pvPairs);

My Matlab version is 7.6.0.324.

Also, I miss an option to switch off end axis notation. I can set AxisLabelLocation to end or side, but not to off. It would also be great to be able to set the tags that are written to the ends of the axes, something like XAxisLabel etc., and to determine whether they should come on both sides or only on the positive side.

- Christian

16 May 2011 John Barber

Christian,

Thanks for the feedback. I'll have a new version posted shortly to address the bug.

The axis labels are implemented similarly to the labels for a normal axes. There are two methods to control the display of the axis labels:

1) Set the 'XLabel', etc. property of the oaxes object. This property is a dummy property that is copied to the 'String' properties of the actual label objects. Because there are labels for both the positive and negative sides of each axis, the 'XLabel' property should be specified as a 2x1 cell array. Use the empty string to suppress display of a particular label.

2) Access the label objects directly using their handles. The handles can be found in the 'hXLabel', etc. properties of the oaxes object. As with the 'XLabel' property, 'hXLabel' contains two handles, one for the positive and one for the negative axis label. Using the handles, you can set text size, font, or any other text object property of each label. Note that the labels will be re-created if you delete the label objects. Set the label to the empty string to hide it.

I'll consider adding an 'off' option to the 'AxisLabelLocation' property in a future update.

Thanks,
John

21 Jun 2011 Dan Knudsen  
21 Jun 2011 Dan Knudsen

Thank you very much for this code! Works well on a variety of applications in 2009b (v7.9.0.529), though I haven't tested all features.

27 Jan 2012 Namgyun

It seems that arrows dispear when a figure is saved as a pdf file with the "print" function in MATLAB.
Could you check this?

Thank you.

Nam

31 Jan 2012 John Barber

Nam,

Thanks for the feedback - I'll take a look at it. For presentation-quality graphics, you might want to try using export_fig to save your figures (link: http://www.mathworks.com/matlabcentral/fileexchange/23629 ).

-John

04 May 2012 Joachim  
Please login to add a comment or rating.
Updates
19 Jan 2011

Several bug fixes, improved text alignment, added new properties, improved help text. See the release notes in the help text for a full description.

10 Mar 2011

- Properties can be accessed using set/get
- Oaxes responds automatically to property changes
- See the release notes for more details

29 Mar 2011

- Full object-oriented version
- 'Extend' limits mode, internal tick calculation, other new features
- Improved graphics refresh speed

01 Apr 2011

- Several minor bug fixes
- Removed unneeded code from constructor method

02 Apr 2011

- Minor bug fix

06 Jun 2011

- Bug fixes
- Improved redraw speed
- Improved appearance of minor ticks

Tag Activity for this File
Tag Applied By Date/Time
graphics John Barber 13 Jan 2011 08:46:33
axis John Barber 13 Jan 2011 08:46:33
centered axis John Barber 13 Jan 2011 08:46:33
origin John Barber 13 Jan 2011 08:46:33
central axis John Barber 13 Jan 2011 08:46:33
axis Andreea Muresan 23 Dec 2011 09:53:08

Contact us at files@mathworks.com