Mercurial > octave
changeset 29024:447beb85551d
Add ytickangle and ztickangle functions (bug #59067)
* scripts/plot/appearance/ytickangle.m: New function.
* scripts/plot/appearance/ztickangle.m: New function.
* scripts/plot/appearance/module.mk: Add ytickangle.m, ztickangle.m to build
system.
* NEWS: Announce addition of xtickangle, ytickangle, ztickangle functions.
* doc/interpreter/plot.txi: Add xtickangle to manual and XREF anchors for
ytickangle and ztickangle.
* __unimplemented__.m: Remove xtickangle, ytickangle, ztickangle from
unimplemented list.
* __tickangle__.m: Fix empty figure popping up during BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 04 Nov 2020 20:18:11 -0800 |
parents | 5e62adcdcaa2 |
children | 7f103819617d |
files | NEWS doc/interpreter/plot.txi scripts/help/__unimplemented__.m scripts/plot/appearance/module.mk scripts/plot/appearance/private/__tickangle__.m scripts/plot/appearance/ytickangle.m scripts/plot/appearance/ztickangle.m |
diffstat | 7 files changed, 206 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Nov 04 19:55:43 2020 -0800 +++ b/NEWS Wed Nov 04 20:18:11 2020 -0800 @@ -169,6 +169,9 @@ * `rng` * `startsWith` * `streamribbon` +* `xtickangle` +* `ytickangle` +* `ztickangle` ### Deprecated functions and properties
--- a/doc/interpreter/plot.txi Wed Nov 04 19:55:43 2020 -0800 +++ b/doc/interpreter/plot.txi Wed Nov 04 20:18:11 2020 -0800 @@ -342,6 +342,16 @@ @findex zticklabels @DOCSTRING(xticklabels) +The @code{xtickangle}, @code{ytickangle}, and @code{ztickangle} functions +may be used to get or set the rotation angle of labels for the respective axis. +Each has the same form. + +@anchor{XREFytickangle} +@anchor{XREFztickangle} +@findex ytickangle +@findex ztickangle +@DOCSTRING(xtickangle) + @node Two-dimensional Function Plotting @subsubsection Two-dimensional Function Plotting @cindex plotting, two-dimensional functions
--- a/scripts/help/__unimplemented__.m Wed Nov 04 19:55:43 2020 -0800 +++ b/scripts/help/__unimplemented__.m Wed Nov 04 20:18:11 2020 -0800 @@ -1319,16 +1319,13 @@ "xmlread", "xmlwrite", "xslt", - "xtickangle", "xtickformat", "year", "years", "ymd", - "ytickangle", "ytickformat", "yyaxis", "yyyymmdd", - "ztickangle", "ztickformat", };
--- a/scripts/plot/appearance/module.mk Wed Nov 04 19:55:43 2020 -0800 +++ b/scripts/plot/appearance/module.mk Wed Nov 04 20:18:11 2020 -0800 @@ -53,10 +53,12 @@ %reldir%/ylabel.m \ %reldir%/ylim.m \ %reldir%/yticks.m \ + %reldir%/ytickangle.m \ %reldir%/yticklabels.m \ %reldir%/zlabel.m \ %reldir%/zlim.m \ %reldir%/zticks.m \ + %reldir%/ztickangle.m \ %reldir%/zticklabels.m %canon_reldir%dir = $(fcnfiledir)/plot/appearance
--- a/scripts/plot/appearance/private/__tickangle__.m Wed Nov 04 19:55:43 2020 -0800 +++ b/scripts/plot/appearance/private/__tickangle__.m Wed Nov 04 20:18:11 2020 -0800 @@ -43,7 +43,7 @@ return; else angle = hax; - hax = gca (); + hax = []; endif case 3 @@ -59,6 +59,10 @@ error ([caller ": function called with output query and input set value"]); endif + if (isempty (hax)) + hax = gca (); + endif + set (hax, [ax, "ticklabelrotation"], angle); endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/appearance/ytickangle.m Wed Nov 04 20:18:11 2020 -0800 @@ -0,0 +1,93 @@ +######################################################################## +## +## Copyright (C) 2020 The Octave Project Developers +## +## See the file COPYRIGHT.md in the top-level directory of this +## distribution or <https://octave.org/copyright/>. +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## <https://www.gnu.org/licenses/>. +## +######################################################################## + +## -*- texinfo -*- +## @deftypefn {} {@var{angle} =} ytickangle () +## @deftypefnx {} {@var{angle} =} ytickangle (@var{hax}) +## @deftypefnx {} {} ytickangle (@var{angle}) +## @deftypefnx {} {} ytickangle (@var{hax}, @var{angle}) +## Query or set the rotation angle of the tick labels on the y-axis of the +## current axes. +## +## When called without an argument, return the rotation angle in degrees of the +## tick labels as specified in the axes property @qcode{"YTickLabelRotation"}. +## When called with a numeric scalar @var{angle}, rotate the tick labels +## counterclockwise to @var{angle} degrees. +## +## If the first argument @var{hax} is an axes handle, then operate on this axes +## rather than the current axes returned by @code{gca}. +## +## Programming Note: Requesting a return value while also setting a specified +## rotation will result in an error. +## +## @seealso{xtickangle, ztickangle, get, set} +## @end deftypefn + +function retval = ytickangle (hax, angle) + + switch (nargin) + case 0 + retval = __tickangle__ (mfilename ()); + + case 1 + if (nargout > 0) + retval = __tickangle__ (mfilename (), hax); + else + __tickangle__ (mfilename (), hax); + endif + + case 2 + if (nargout > 0) + retval = __tickangle__ (mfilename (), hax, angle); + else + __tickangle__ (mfilename (), hax, angle); + endif + + endswitch + +endfunction + + +%!test +%! hf = figure ("visible", "off"); +%! hax = axes (hf); +%! unwind_protect +%! ytickangle (45); +%! assert (ytickangle (), 45); +%! ytickangle (hax, 90); +%! a1 = ytickangle (); +%! a2 = ytickangle (hax); +%! assert (a1, a2); +%! assert (a1, 90); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +## Test input validation +%!error <HAX must be a handle to an axes object> ytickangle (0, 45) +%!error <ANGLE must be .* scalar> ytickangle (eye (2)) +%!error <ANGLE must be .* numeric> ytickangle ({90}) +%!error <ANGLE must be .* finite> ytickangle (Inf) +%!error <called with output query and input set value> ang = ytickangle (45)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/plot/appearance/ztickangle.m Wed Nov 04 20:18:11 2020 -0800 @@ -0,0 +1,93 @@ +######################################################################## +## +## Copyright (C) 2020 The Octave Project Developers +## +## See the file COPYRIGHT.md in the top-level directory of this +## distribution or <https://octave.org/copyright/>. +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## <https://www.gnu.org/licenses/>. +## +######################################################################## + +## -*- texinfo -*- +## @deftypefn {} {@var{angle} =} ztickangle () +## @deftypefnx {} {@var{angle} =} ztickangle (@var{hax}) +## @deftypefnx {} {} ztickangle (@var{angle}) +## @deftypefnx {} {} ztickangle (@var{hax}, @var{angle}) +## Query or set the rotation angle of the tick labels on the z-axis of the +## current axes. +## +## When called without an argument, return the rotation angle in degrees of the +## tick labels as specified in the axes property @qcode{"ZTickLabelRotation"}. +## When called with a numeric scalar @var{angle}, rotate the tick labels +## counterclockwise to @var{angle} degrees. +## +## If the first argument @var{hax} is an axes handle, then operate on this axes +## rather than the current axes returned by @code{gca}. +## +## Programming Note: Requesting a return value while also setting a specified +## rotation will result in an error. +## +## @seealso{xtickangle, ytickangle, get, set} +## @end deftypefn + +function retval = ztickangle (hax, angle) + + switch (nargin) + case 0 + retval = __tickangle__ (mfilename ()); + + case 1 + if (nargout > 0) + retval = __tickangle__ (mfilename (), hax); + else + __tickangle__ (mfilename (), hax); + endif + + case 2 + if (nargout > 0) + retval = __tickangle__ (mfilename (), hax, angle); + else + __tickangle__ (mfilename (), hax, angle); + endif + + endswitch + +endfunction + + +%!test +%! hf = figure ("visible", "off"); +%! hax = axes (hf); +%! unwind_protect +%! ztickangle (45); +%! assert (ztickangle (), 45); +%! ztickangle (hax, 90); +%! a1 = ztickangle (); +%! a2 = ztickangle (hax); +%! assert (a1, a2); +%! assert (a1, 90); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +## Test input validation +%!error <HAX must be a handle to an axes object> ztickangle (0, 45) +%!error <ANGLE must be .* scalar> ztickangle (eye (2)) +%!error <ANGLE must be .* numeric> ztickangle ({90}) +%!error <ANGLE must be .* finite> ztickangle (Inf) +%!error <called with output query and input set value> ang = ztickangle (45)