Mercurial > octave
changeset 28612:bdc53d9affb2 stable
legend.m: Fix other regression introduced in cset 26d69b0a3e8d (bug #58822)
* legend.m (boxposition): Accept two more argument, plotboxaspectratiomode and
dataaspectratiomode, and return the original position if both are "auto".
(update_legend_position): update all uses.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sun, 02 Aug 2020 16:16:31 +0200 |
parents | 7b2f5b2ddbdb |
children | b11f026bc443 c315a866dbe9 |
files | scripts/plot/appearance/legend.m |
diffstat | 1 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/legend.m Mon Aug 03 10:36:57 2020 -0400 +++ b/scripts/plot/appearance/legend.m Sun Aug 02 16:16:31 2020 +0200 @@ -1280,10 +1280,17 @@ endswitch endfunction -function pos = boxposition (axpos, pba) +function pos = boxposition (axpos, pba, pbam, dam) + pos = axpos; + + if (strcmp (pbam, "auto") && strcmp (dam, "auto")) + return; + endif + pbratio = pba(1)/pba(2); posratio = axpos(3)/axpos(4); + if (pbratio != posratio) if (posratio < pbratio) pos(4) = pos(3) / pbratio; @@ -1293,6 +1300,7 @@ pos(1) += (axpos(3) - pos(3)) / 2; endif endif + endfunction function update_legend_position (hl, sz) @@ -1349,11 +1357,9 @@ "plotboxaspectratiomode", ... "plotboxaspectratio", ... "dataaspectratiomode"}){:}; - - if (strcmp (pbam, "manual") || strcmp (dam, "manual")) - axpos = boxposition (axpos, pba); - endif - + + axpos = boxposition (axpos, pba, pbam, dam); + lpos = [get(hl, "position")(1:2), sz]; if (! outside) @@ -1408,7 +1414,7 @@ if (axpos(1) < (dx + hmargin)) li(1) = min (dx + hmargin, 0.95 * (axpos(1) + axpos(3))); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) - dx; lpos(2) = axpos(2); @@ -1417,7 +1423,7 @@ if (axpos(1) < (dx + hmargin)) li(1) = min (dx + hmargin, 0.95 * (axpos(1) + axpos(3))); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) - dx; lpos(2) = axpos(2) + axpos(4)/2 - lpos(4)/2; @@ -1426,7 +1432,7 @@ if (axpos(1) < (dx + hmargin)) li(1) = min (dx + hmargin, 0.95 * (axpos(1) + axpos(3))); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) - dx; lpos(2) = axpos(2) + axpos(4) - lpos(4); @@ -1435,7 +1441,7 @@ if (li(4) < (dy + vmargin)) li(4) = min (dy + vmargin, axpos(4)); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) + axpos(3)/2 - lpos(3)/2; lpos(2) = axpos(2) + axpos(4) + vmargin + ti(4); @@ -1444,7 +1450,7 @@ if (li(3) < (dx + hmargin)) li(3) = min (dx + hmargin, axpos(3)); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) + axpos(3) + hmargin + ti(3); lpos(2) = axpos(2) + axpos(4) - lpos(4); @@ -1453,7 +1459,7 @@ if (li(3) < (dx + hmargin)) li(3) = min (dx + hmargin, axpos(3)); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) + axpos(3) + hmargin + ti(3); lpos(2) = axpos(2) + axpos(4)/2 - lpos(4)/2; @@ -1462,7 +1468,7 @@ if (li(3) < (dx + hmargin)) li(3) = min (dx + hmargin, axpos(3)); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) + axpos(3) + hmargin + ti(3); lpos(2) = axpos(2); @@ -1471,7 +1477,7 @@ if (li(2) < (dy + vmargin)) li(2) = min (dy + vmargin, 0.95 * (axpos(2) + axpos(4))); set (hax, "looseinset", li); - axpos = boxposition (get (hax, "position"), pbam, pba); + axpos = boxposition (get (hax, "position"), pba, pbam, dam); endif lpos(1) = axpos(1) + axpos(3)/2 - lpos(3)/2; lpos(2) = axpos(2) - lpos(4) - vmargin - ti(2);