# HG changeset patch # User Markus Mützel # Date 1640445052 -3600 # Node ID 4d2b528464ad7ed4de315bcc4b19cf67f55a1e8a # Parent 7bd9ecd4a0a5afdfbaf950bc4f9d9404fa3297e3 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 diff -r 7bd9ecd4a0a5 -r 4d2b528464ad scripts/plot/util/newplot.m --- 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