Rank: 692 based on 208 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 graphics, axis, centered axis, central axis, origin, arrow 73 18
  • 4.875
4.9 | 8 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... 31 2
  • 5.0
5.0 | 3 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 23 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 16 0
29 Mar 2011 Screenshot calcticks Calculate ticks and ticklabels for specified limits, orientation and text size. Author: John Barber ticks, tick, tick labels, ticklabel, axis, graphics 19 0
Comments and Ratings by John View all
Updated File Comments Rating
22 May 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

@Mikael: Thank you for the kind feedback. You can try Christian's modification to not display negative arrows. See his comment from 05 Jan 2013 for a link. (Disclaimer: I have not tested this code). I'll think about adding this functionality in my next update, but I'll have to put some thought into the best way to implement it.

Adding grid lines has been on my todo list for a while. Hopefully I'll have some time in the next month or two to work on it. Right now, if you want grid lines, you have to un-hide the parent axes (oa.HideParentAxes = 'off') and turn the grid on as usual. Unfortunately, you end up with the parent axes' axis lines, ticks and tick labels as well - it gets kind of cluttered.

@Christian: Thanks for the kind feedback. I'll take a look at your modified code and consider adding it as an option in my next update.

@cpas1940: If you want to change the label rotation, you can access the handles of the labels in oa.hXLabel, oa.hYLabel, etc. Then you can set the 'Rotation' property as well as any other text properties directly. I'm not sure what you mean by 'having the ylabel centered at (0,0)'. If one of the ylabels were located at (0,0) it would no longer be a label on the end of the axis (assuming oaxes is centered at (0,0) and the limits are [-a +b]). If you are talking about having a rotated label be centered around the y axis line, you can play with the 'HorizontalAlignment' and 'VerticalAlignment' text properties of the labels. Here is an example:

oa = oaxes;
set(oa.hYLabel(1),'Rotation',90)
% (The negative-axis label is now rotated by 90 degrees, but not centered correctly)
set(oa.hYLabel(1),'HorizontalAlignment','right','VerticalAlignment','middle')
% (Now it is centered and no longer overlapping the end of the axis line)

-John

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

Comments and Ratings on John's Files View all
Updated File Comment by Comments Rating
03 Apr 2014 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Crescenzio, Giuseppe

Hi, I have a problem. I'm making a GUI to show easy roto-translation. Therefore I have to print more reference system on the same plot.
1) oaxes seems to ignore the hold on command. I cannot plot 2 coordinate system on the same plot.
2) can I reset the origin? I mean image I have a point with coordinates (1,2,3) if I translate a reference system form (0,0,0) to i.e. the point (2,2,2)the new coordinates for the point with respect to the new reference system centered in (2,2,2) are (-1,0,1). thus if I give the command oaxes([2 2 2]) what I get is a new reference sys in the point (2,2,2)but the scale reading is wrong(1,2,3) r better is correct wrt the previous ref system.
Is it possible to give an offset to the scale in order to fix it?
I wish to shoe you an image...
thanks
Giuseppe

19 Jun 2013 xtickinterval, ytickinterval XTICKINTERVAL forces tick spacing to a specified interval regardless of axis limits. Author: John Barber Baughman, Eowyn

Works, but with plotyy when you ask it to adjust the interval on AX(1), it also places ticks on AX(2). You can still set AX(2) but you'll have ticks from AX(1) as well.

18 Jun 2013 logzplot Easily create surface plots with logarithmic z-axis and color scale. Author: John Barber Rhys

13 Jun 2013 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber Felix

I am missing a few functions or can't find them:
-How can I make the ticklabels appear on the outisde of the axis instead inside?
-Is it possible to define the minor ticks separately?
-Is it possible to set multiple axis limits (to make it appear like multiple small axis instead of one long axisLine)

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

@Mikael: Thank you for the kind feedback. You can try Christian's modification to not display negative arrows. See his comment from 05 Jan 2013 for a link. (Disclaimer: I have not tested this code). I'll think about adding this functionality in my next update, but I'll have to put some thought into the best way to implement it.

Adding grid lines has been on my todo list for a while. Hopefully I'll have some time in the next month or two to work on it. Right now, if you want grid lines, you have to un-hide the parent axes (oa.HideParentAxes = 'off') and turn the grid on as usual. Unfortunately, you end up with the parent axes' axis lines, ticks and tick labels as well - it gets kind of cluttered.

@Christian: Thanks for the kind feedback. I'll take a look at your modified code and consider adding it as an option in my next update.

@cpas1940: If you want to change the label rotation, you can access the handles of the labels in oa.hXLabel, oa.hYLabel, etc. Then you can set the 'Rotation' property as well as any other text properties directly. I'm not sure what you mean by 'having the ylabel centered at (0,0)'. If one of the ylabels were located at (0,0) it would no longer be a label on the end of the axis (assuming oaxes is centered at (0,0) and the limits are [-a +b]). If you are talking about having a rotated label be centered around the y axis line, you can play with the 'HorizontalAlignment' and 'VerticalAlignment' text properties of the labels. Here is an example:

oa = oaxes;
set(oa.hYLabel(1),'Rotation',90)
% (The negative-axis label is now rotated by 90 degrees, but not centered correctly)
set(oa.hYLabel(1),'HorizontalAlignment','right','VerticalAlignment','middle')
% (Now it is centered and no longer overlapping the end of the axis line)

-John

Contact us