annotate scripts/plot/appearance/xticklabels.m @ 26376:00f796120a6d stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:32:43 -0500
parents 6652d3823428
children b442ec6dda5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
1 ## Copyright (C) 2017-2019 Nicholas Jankowski
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
2 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
3 ## This file is part of Octave.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24507
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24507
diff changeset
7 ## the Free Software Foundation, either version 3 of the License, or
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
8 ## (at your option) any later version.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
9 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
13 ## GNU General Public License for more details.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
14 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24507
diff changeset
17 ## <https://www.gnu.org/licenses/>.
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
18
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
19 ## -*- texinfo -*-
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
20 ## @deftypefn {} {@var{tickval} =} xticklabels
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
21 ## @deftypefnx {} {@var{mode} =} xticklabels ("mode")
24507
dc25a0dc7800 Correct a host of small formatting issues with Texinfo manual (bug #52774)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24208
diff changeset
22 ## @deftypefnx {} {} xticklabels (@var{tickval})
dc25a0dc7800 Correct a host of small formatting issues with Texinfo manual (bug #52774)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24208
diff changeset
23 ## @deftypefnx {} {} xticklabels ("auto")
dc25a0dc7800 Correct a host of small formatting issues with Texinfo manual (bug #52774)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24208
diff changeset
24 ## @deftypefnx {} {} xticklabels ("manual")
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
25 ## @deftypefnx {} {@dots{} =} xticklabels (@var{hax}, @dots{})
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
26 ## Query or set the tick labels on the x-axis of the current axis.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
27 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
28 ## When called without an argument, return a cell array of strings of the
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
29 ## current tick labels as specified in the @qcode{"xticklabel"} axes property.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
30 ## These labels can be changed by calling @code{xticklabels} with a cell array
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
31 ## of strings. Note: a vector of numbers will be mapped to a cell array of
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
32 ## strings. If fewer labels are specified than the current number of ticks,
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
33 ## blank labels will be appended to the array.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
34 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
35 ## When called with argument @qcode{"mode"}, @code{xticklabels} returns the
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
36 ## current value of the axes property @qcode{"xticklabelmode"}. This property
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
37 ## can be changed by calling @code{xticklabels} with either @qcode{"auto"}
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
38 ## (algorithm determines tick labels) or @qcode{"manual"} (tick labels remain
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
39 ## fixed). Note: Specifying xticklabel values will also set the
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
40 ## @qcode{"xticklabelmode"} and @qcode{"xticks"} properties to
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
41 ## @qcode{"manual"}.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
42 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
43 ## If the first argument @var{hax} is an axes handle, then operate on
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
44 ## this axis rather than the current axes returned by @code{gca}.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
45 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
46 ## Requesting a return value when calling @code{xticklabels} to set a property
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
47 ## value will result in an error.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
48 ##
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
49 ## @seealso{xticks, yticklabels, zticklabels, get, set}
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
50 ## @end deftypefn
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
51
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
52 ## Author: Nicholas Jankowski <jankowskin@asme.org>
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
53 ## Created: 2017-08-24
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
54
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
55 function retval = xticklabels (varargin)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
56
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
57 hax = [];
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
58 switch (nargin)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
59 case 0
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
60 retval = get (gca , "xticklabel"); # will error if no xticklabel exists.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
61 return;
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
62
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
63 case 1
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
64 if (isaxes (varargin{1}))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
65 retval = get (varargin{1}, "xticklabel");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
66 return;
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
67 else
24208
eec262017c6a maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 24050
diff changeset
68 arg = varargin{1};
24050
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
69 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
70
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
71 case 2
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
72 if (! isaxes (varargin{1}))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
73 error ("xticklabels: HAX must be a handle to an axes object");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
74 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
75 hax = varargin{1};
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
76 arg = varargin{2};
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
77
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
78 otherwise
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
79 print_usage ();
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
80
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
81 endswitch
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
82
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
83 if (isempty (hax))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
84 hax = gca ();
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
85 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
86
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
87 if (iscell (arg) || isnumeric (arg))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
88 if (nargout > 0)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
89 error ("xticklabels: too many output arguments requested");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
90 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
91
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
92 if (isnumeric (arg))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
93 ## NOTE: Matlab accepts a cell array, but a non-vector numeric array will
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
94 ## simply produce a black set of labels without error or warning.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
95 ## This implementation allows for a numeric array, which is handled in
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
96 ## the same order as Matlab handles a cell array
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
97 arg = num2cell (arg(:));
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
98
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
99 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
100
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
101 ## Convert any numeric elements to characters, make it a 1D cell array.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
102 arg = cellfun (@num2str, arg, "UniformOutput", false)(:);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
103
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
104 ## Pad with blank cell entries if needed.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
105 arg((numel (arg) + 1):(numel (get (hax, "xtick")))) = {""};
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
106
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
107 ## Setting labels sets both ticklabel and tick mode to manual.
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
108 set (hax, "xticklabel", arg,
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
109 "xticklabelmode", "manual",
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
110 "xtickmode", "manual");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
111
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
112 elseif (ischar (arg))
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
113 arg = tolower (arg);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
114 switch (arg)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
115 case "mode"
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
116 retval = get (hax, "xticklabelmode");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
117
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
118 case {"auto", "manual"}
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
119 if (nargout > 0)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
120 error (["xticklabels: " ...
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
121 "too many output arguments requested for arg: ", arg]);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
122 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
123 set (hax, "xticklabelmode", arg);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
124
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
125 otherwise
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
126 error ("xticklabels: invalid option: %s", arg);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
127
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
128 endswitch
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
129
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
130 else
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
131 print_usage ();
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
132 endif
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
133
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
134 endfunction
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
135
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
136
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
137 %!test
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
138 %! hf = figure ("visible", "off");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
139 %! unwind_protect
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
140 %! set (gca, "xticklabelmode", "auto");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
141 %! hax = gca;
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
142 %! vals1 = xticklabels;
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
143 %! assert (xticklabels (hax), vals1);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
144 %! mode1 = xticklabels ("mode");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
145 %! assert (xticklabels (hax, "mode"), mode1);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
146 %! xticklabels (hax, "manual");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
147 %! assert (xticklabels (hax, "mode"), "manual");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
148 %! xticklabels (hax, "auto");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
149 %! assert (xticks (hax, "mode"), "auto");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
150 %! xticklabels (hax, {"1", "2", "3", "4", "5", "6"});
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
151 %! assert (xticklabels (hax), {"1"; "2"; "3"; "4"; "5"; "6"});
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
152 %! assert (xticklabels (hax, "mode"), "manual");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
153 %! assert (xticks (hax, "mode"), "manual");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
154 %! unwind_protect_cleanup
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
155 %! close (hf);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
156 %! end_unwind_protect
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
157
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
158 ## Test input validation
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
159 %!error xticklabels (1,2,3)
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
160 %!test
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
161 %! hf = figure ("visible", "off");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
162 %! unwind_protect
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
163 %! hax = gca;
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
164 %! fail ("xticklabels (-1, {})", "HAX must be a handle to an axes");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
165 %! fail ("tmp = xticklabels (hax, {'A','B'})", "too many output arguments");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
166 %! fail ("tmp = xticklabels (hax, [0, 1])", "too many output arguments");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
167 %! fail ("tmp = xticklabels (hax, 'auto')", "too many .* for arg: auto");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
168 %! fail ("tmp = xticklabels (hax, 'foo')", "invalid option: foo");
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
169 %! unwind_protect_cleanup
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
170 %! close (hf);
a03bb64031da Implement missing axis tick and label functions (bug #51839).
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
diff changeset
171 %! end_unwind_protect