## Copyright (C) 2017 Nicholas Jankowski ## ## This program is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {} {@var{rtick_values} =} rticks ## @deftypefnx {} rticks (@var{'rtick_values'}) ## @deftypefnx {} rticks (@var{hax}, @dots{}) ## Query or set the properties related to tick values on the r-axis of the ## current axis. ## ## When @code{rticks} is called without argument, @code{rticks} returns the ## current locations as specified in the @var{rtick} axis property. These values ## can be changed by calling @code{rticks} with a vector of tick values. Note: ## ascending order is not required. ## ## If the first argument @var{hax} is an axes handle, then operate on ## this axis rather than the current axes returned by @code{gca}. ## ## Requesting a return value when calling @code{rticks} to set a property value ## will result in an error. ## ## NOTE: Octave does not currently have polaraxes obects implented. It is ## not currently possible to query or set a 'mode' for the @var{rtick} property ## as can be done with equivalent functions for @var{x}, @var{y} and @var{z} ## axes. ## ## @seealso{thetaticks, xticks, yticks, zticks, polar, get, set} ## @end deftypefn ## Author: Nicholas Jankowski ## Created: 2017-08-24 function [retval] = rticks (varargin) #identify and set input values, shortcut simple cases switch nargin case 0 retval = get (gca , 'rtick'); #will error if no rtick exists. return; case 1 axis_to_use = gca; option = varargin{1}; case 2 #if 2 inputs, first must specify an axis handle. if (~ishandle (varargin{1}) || ishandle (varargin{2})) print_usage; else axis_to_use = varargin{1}; option = varargin{2}; endif otherwise print_usage; endswitch # axis and option are set, perform requested actions based on 'option' class if ishandle(option) retval = get (option, 'rtick'); elseif ischar(option) error('mode is currently not implemented for the rtick property') ## FIXME: enable mode options if/when they are enabled in polar or polarplot ## option = tolower(option); ## switch option ## case 'mode' ## retval = get (axis_to_use, 'rtickmode'); ## ## case {'auto','manual'} ## if (nargout > 0) ## error(['too many output arguments requested for option "', option, '"']) ## else ## set(axis_to_use, 'rtickmode', option); ## endif ## otherwise ## error(['invalid option "', option, '"']) ## endswitch elseif (isnumeric(option)) if (nargout > 0) error('too many output arguments requested') else ## NOTE: Matlab errors if tick points are not in ascending order. Octave ## permits out of order tick points, so error is not produced. set(axis_to_use, 'rtick', option); endif else print_usage; endif endfunction ## Test input validation %!test %! hf = figure ("visible", "off"); %! unwind_protect %! polar (linspace (0, pi, 20), rand(20,1)); %! hax = gca; %! vals1 = rticks; %! assert (rticks (hax), vals1); %! rticks (hax, [0 0.25 0.75 1 2]); %! assert (rticks (hax), [0 0.25 0.75 1 2]); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect