Rank: 626 based on 182 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 81 23
  • 4.9
4.9 | 10 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... 23 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 16 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 10 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 20 1
  • 5.0
5.0 | 1 rating
Comments and Ratings by John View all
Updated File Comments Rating
31 May 2014 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

@Giuseppe:
1) See my answer and suggested workaround to Felix's question about multiple OAXES. It is not currently possible to have more than one OAXES exist in a given axes. I will consider it for a future release.

2) There is not a way to specify an offset. If you want to show a translated coordinate system, you could simply set the tick labels of the OAXES object to custom values representing the translated coordinates. Be sure to set the tick labels and not the ticks themselves. This trick also works on the standard MATLAB axes object - the tick labels can be independent of the values of the ticks. The drawback is that if the tick locations change (due to limit changes, etc.), the manual tick labels will be incorrect. I'll consider adding an 'offset' property in a future release.

31 May 2014 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

@Sebastian:
Like many of the low-level MATLAB graphics functions, OAXES does not redraw until the MATLAB event queue is processed, which doesn't necessarily happen when you would like it to during function execution. Instead of using the PAUSE command, you can call the MATLAB function DRAWNOW() (see the help file for DRAWNOW for more information). Alternately, you can force the OAXES object to redraw by calling its DRAW() method. If you have a handle OA to the OAXES, simply call OA.draw(). If you don't have the handle, calling oaxes('draw') should also work as long as it can find the OAXES object.

I'm not sure what you mean by "rotate the axis". In 3D views, the axis lines rotate along with all other drawing objects as the camera location is moved. Trying to keep the displayed axis lines fixed on camera moves means that the lines would no longer correspond to the coordinate system. Although it would be interesting to create a camera-independent display mode for a given object (e.g. apply a transform to the object that undoes the effects of the camera location change), that is not in line with the motivation for writing OAXES.

31 May 2014 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber

@Felix:
(1) I'm not sure what you mean by inside vs. outside the axis. If you are referring to which side of the axis line the labels are drawn on, then there is currently no way to specify this, but I'll consider adding one in the next release. If you are referring to inside and outside of the plot box/cube, OAXES always draws the labels next to the axis lines, which are always inside of the box.

(2) No, it is not currently possible to define minor ticks. They are calculated automatically for log-scale axes, and not shown for linear scaling. This capability might be added in a future release.

(3) It is not possible for more than one OAXES to exist inside of a given axes. If you want to show more than one OAXES on a given plot, you could try overlaying additional axes objects with transparent backgrounds, and limits linked to the original axes, each containing an OAXES object. See the MATLAB functions linkaxes() and linkprop() for more information.

31 May 2014 xtickinterval, ytickinterval XTICKINTERVAL forces tick spacing to a specified interval regardless of axis limits. Author: John Barber

@Eowyn: Unfortunately, it is not possible in general to use a single fixed interval for two different ranges and have the ticks line up. Conversely, if XTICKINTERVAL were to enforce aligned ticks for two ranges, the interval used for the second axis might be fixed at some odd, unhelpful value.

Although it is difficult to see a good solution for the general case of a single interval for multiple ranges, there are some cases where the resulting tick locations would be acceptable. I'll take a look at some methods to handle those cases.

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

Comments and Ratings on John's Files View all
Updated File Comment by Comments Rating
21 Aug 2014 calcticks Calculate ticks and ticklabels for specified limits, orientation and text size. Author: John Barber Greene, Chad

This submission is well written and very well documented. It quite nicely solves the problem of creating ticks that are easy to read. Thank you for sharing.

21 Aug 2014 oaxes - central axis lines through an origin Draw central axis lines through an origin point. Author: John Barber de Haas, Paul

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

@Giuseppe:
1) See my answer and suggested workaround to Felix's question about multiple OAXES. It is not currently possible to have more than one OAXES exist in a given axes. I will consider it for a future release.

2) There is not a way to specify an offset. If you want to show a translated coordinate system, you could simply set the tick labels of the OAXES object to custom values representing the translated coordinates. Be sure to set the tick labels and not the ticks themselves. This trick also works on the standard MATLAB axes object - the tick labels can be independent of the values of the ticks. The drawback is that if the tick locations change (due to limit changes, etc.), the manual tick labels will be incorrect. I'll consider adding an 'offset' property in a future release.

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

@Sebastian:
Like many of the low-level MATLAB graphics functions, OAXES does not redraw until the MATLAB event queue is processed, which doesn't necessarily happen when you would like it to during function execution. Instead of using the PAUSE command, you can call the MATLAB function DRAWNOW() (see the help file for DRAWNOW for more information). Alternately, you can force the OAXES object to redraw by calling its DRAW() method. If you have a handle OA to the OAXES, simply call OA.draw(). If you don't have the handle, calling oaxes('draw') should also work as long as it can find the OAXES object.

I'm not sure what you mean by "rotate the axis". In 3D views, the axis lines rotate along with all other drawing objects as the camera location is moved. Trying to keep the displayed axis lines fixed on camera moves means that the lines would no longer correspond to the coordinate system. Although it would be interesting to create a camera-independent display mode for a given object (e.g. apply a transform to the object that undoes the effects of the camera location change), that is not in line with the motivation for writing OAXES.

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

@Felix:
(1) I'm not sure what you mean by inside vs. outside the axis. If you are referring to which side of the axis line the labels are drawn on, then there is currently no way to specify this, but I'll consider adding one in the next release. If you are referring to inside and outside of the plot box/cube, OAXES always draws the labels next to the axis lines, which are always inside of the box.

(2) No, it is not currently possible to define minor ticks. They are calculated automatically for log-scale axes, and not shown for linear scaling. This capability might be added in a future release.

(3) It is not possible for more than one OAXES to exist inside of a given axes. If you want to show more than one OAXES on a given plot, you could try overlaying additional axes objects with transparent backgrounds, and limits linked to the original axes, each containing an OAXES object. See the MATLAB functions linkaxes() and linkprop() for more information.

Contact us