Rank: 751 based on 121 downloads (last 30 days) and 8 files submitted
photo

John Barber

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by John View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
07 Aug 2012 Screenshot oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber axis, central axis, centered axis, graphics, origin, arrow 84 12
  • 5.0
5.0 | 6 ratings
31 May 2012 Screenshot logzplot Easily create surface plots with logarithmic z-axis and color scale. Author: John Barber surface plot, logscaled surface plo..., logscaled plot, logscaled color, logarithmic scaling, log scaled surface pl... 12 2
  • 5.0
5.0 | 2 ratings
06 Jun 2011 Screenshot riemannsphere Plot complex numbers on a Riemann sphere Author: John Barber riemann sphere, complex numbers, complex data, stereographic project..., graphics 3 1
  • 5.0
5.0 | 1 rating
29 Mar 2011 Screenshot obliqueview Obliqueview - View an axes using an oblique projection Author: John Barber graphics, oblique, oblique projection, projection, orthographic projecti..., potw 4 0
29 Mar 2011 Screenshot calcticks Calculate ticks and ticklabels for specified limits, orientation and text size. Author: John Barber tick, tick labels, ticklabel, ticks, axis, graphics 4 0
Comments and Ratings by John View all
Updated File Comments Rating
30 Apr 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

Heather,

The 'HideParentAxes' property controls the visibility of the box around the figure. The default value of 'on' will hide the box, ticks/ticklabels and other features of the parent axes object. You can set this property to 'off', either in the call to generate the oaxes object, or on an existing oaxes object using a function call, set(), or dot notation:
oaxes('HideParentAxes','off');
set(OA,'HideParentAxes','off');
OA.HideParentAxes = 'off';

As you already discovered, the labels for each axis come in pairs (unlike a normal MATLAB axes). The labels should be specified as a <2x1 cell> containing the negative and positive labels, and simply setting the negative label to the empty string will hide it. For example:
OA.XLabel = {'';'+X'};

-John

25 Jul 2012 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

Mukilan,

Thanks for the feedback. I could not reproduce your problem exactly, but here is some information that might be helpful:

Your example code is setting the 'XTickLabel', 'FontName', etc. properties of the parent MATLAB axes (the handle returned by gca), not the properties of the oaxes object. (However, your code does directly set the oaxes object's 'XLabel', 'XColor', etc. properties, and you do not indicate any problem with this part of your code). As documented in the oaxes help, upon initialization, the various text properties of the parent axes are copied to the oaxes, but are then independent. Your code will have no effect on the oaxes tick label font properties. To set the oaxes object's tick label font properties, use the following syntax:

set(oa,'TickLabelFontName','Times New Roman','TickLabelFontSize',14,...)

Note that the pertinent property names for the oaxes object all start with 'TickLabel', unlike the MATLAB axes object. See the oaxes help for a complete list of property names. (I'm not sure why I named them that way - if it bugs enough people, I'll change the names to correspond to the MATLAB axes properties). For both oaxes and MATLAB axes objects, you cannot set different text properties for the x and y axis tick labels - the properties affect each axis.

There is a bug in oaxes that in some cases (including the default case) results in the tick labels not being redrawn when the tick label text properties are changed. I will release an update shortly to fix this. For now, the workaround is to force a redraw after changing the tick label text properties using any of the following (where oa is the handle of the oaxes object):

oa.draw
oaxes('draw')
oaxes draw

Your code sets the 'XTickLabel' property of the parent axes, but not the 'XTick' property. I strongly recommend not doing this because it can lead to incorrect tick labels. For example, type xlim([-1 5]) after setting the 'XTickLabel' property as you specified in your example code. Note that the displayed tick labels do not correspond to the values of the ticks. To avoid this, always set both the 'XTick' and 'XTickLabel' properties together, and when changing back to 'auto' mode for tick placement and labeling, make sure both the 'XTicKMode' and 'XTickLabelMode' are 'auto'. See the MATLAB documentation for 'Axes Properties' for more information.
The behavior of oaxes is identical to the MATLAB axes object in this regard. So if you want to put tick labels at specified locations, set both the 'XTick' and 'XTickLabel' properties of the oaxes object, or just set the 'XTick' property and make sure 'XTickLabelMode' is set to 'auto' (the default). Note that the default behavior of oaxes ticks is to mirror the parent axes tick values ('XTickMode' is set to 'parent' by default). So, unlike the tick label text properties, any changes you make to the parent axes tick values are copied to the oaxes ticks. If you set the 'XTick' property to your own values, 'XTickMode' changes to 'manual'. You can also set it to 'auto' to have oaxes calculate the tick placement rather than copy the parent axes. See the oaxes documentation for more information.

Also note that your example code has errors in the final two 'set' statements - where it reads:

set(gca('XTickLabel'),...

it should say:

set(gca,'XTickLabel',...

31 May 2012 logzplot Easily create surface plots with logarithmic z-axis and color scale. Author: John Barber

Felipe,

Thanks for the suggestions. I've included them in the latest version.

-John

31 Jan 2012 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: 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

16 May 2011 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: 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

Comments and Ratings on John's Files View all
Updated File Comment by Comments Rating
02 May 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Jawahir

30 Apr 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Barber, John

Heather,

The 'HideParentAxes' property controls the visibility of the box around the figure. The default value of 'on' will hide the box, ticks/ticklabels and other features of the parent axes object. You can set this property to 'off', either in the call to generate the oaxes object, or on an existing oaxes object using a function call, set(), or dot notation:
oaxes('HideParentAxes','off');
set(OA,'HideParentAxes','off');
OA.HideParentAxes = 'off';

As you already discovered, the labels for each axis come in pairs (unlike a normal MATLAB axes). The labels should be specified as a <2x1 cell> containing the negative and positive labels, and simply setting the negative label to the empty string will hide it. For example:
OA.XLabel = {'';'+X'};

-John

08 Apr 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Moreland, Heather

Nevermind...I figured that out. Now is there a way to keep the box around the outside of the figure?

08 Apr 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Moreland, Heather

This is great! I am wondering if there is a way to remove the axes labels and use the xlabel and ylabel in the property editor. Specfically, I do not want the "negative" axis labels. The code is

function z=graph(x)
a=0.5;
%
xmin=-0.4;
xmax=1.4;
dx=0.01;
%
x=[xmin:dx:xmax];
%
z=x.*(1-x).*(x-a);
%
plot(x,z)
oaxes([0,0,0],'Arrow','off')

Thanks.
-Heather

02 Mar 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Karampasis, Michael

Great file!It really did the job for me!
Gongats to the creator John Barber!

Top Tags Applied by John
graphics, complex numbers, ticks, axis, centered axis
Files Tagged by John View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
07 Aug 2012 Screenshot oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber axis, central axis, centered axis, graphics, origin, arrow 84 12
  • 5.0
5.0 | 6 ratings
31 May 2012 Screenshot logzplot Easily create surface plots with logarithmic z-axis and color scale. Author: John Barber surface plot, logscaled surface plo..., logscaled plot, logscaled color, logarithmic scaling, log scaled surface pl... 12 2
  • 5.0
5.0 | 2 ratings
06 Jun 2011 Screenshot riemannsphere Plot complex numbers on a Riemann sphere Author: John Barber riemann sphere, complex numbers, complex data, stereographic project..., graphics 3 1
  • 5.0
5.0 | 1 rating
29 Mar 2011 Screenshot obliqueview Obliqueview - View an axes using an oblique projection Author: John Barber graphics, oblique, oblique projection, projection, orthographic projecti..., potw 4 0
29 Mar 2011 Screenshot calcticks Calculate ticks and ticklabels for specified limits, orientation and text size. Author: John Barber tick, tick labels, ticklabel, ticks, axis, graphics 4 0

Contact us