Mercurial > octave
changeset 30551:4d2b528464ad stable
newplot.m: Restore axes position after resetting plotyy axes.
* scripts/plot/util/newplot.m: Restore axes position after resetting plotyy
axes. Add test.
See https://octave.discourse.group/t/1951
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 25 Dec 2021 16:10:52 +0100 |
parents | 7bd9ecd4a0a5 |
children | 752b71dc41f8 117ebe363f56 |
files | scripts/plot/util/newplot.m |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/newplot.m Sat Dec 25 13:55:13 2021 +0100 +++ b/scripts/plot/util/newplot.m Sat Dec 25 16:10:52 2021 +0100 @@ -199,8 +199,10 @@ && ! any (strcmp({dbstack().name}, "plotyy"))) ## Hack for bug #44246. There is no way to reset or remove a ## property created with addproperty short of deleting the object. + old_units = get (ca, "units"); + old_position = get (ca, "position"); delete (ca); - ca = axes (); + ca = axes ("units", old_units, "position", old_position); elseif (do_reset) rcn = getappdata (ca, "__subplotrcn__"); delete (allchild (ca)); @@ -266,3 +268,15 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect + +%!test +%! hf = figure ("visible", "off"); +%! unwind_protect +%! hax = axes ("units", "normalized", "position", [0.1, 0.1, 0.8, 0.3]); +%! plotyy (hax, 1:4, 1:4, 1:4, 4:-1:1); +%! hax2 = newplot (); +%! assert (get (hax2, "units"), "normalized"); +%! assert (get (hax2, "position"), [0.1, 0.1, 0.8, 0.3]); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect