Mercurial > octave
changeset 27747:7ae72862b542
legend.m: handle colormap also for non figure parent (bug #57303)
* legend.m: Create the legend axes under the same parent as its peer axes. Add
listener to the ancestor figure "colormap" property.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 26 Nov 2019 13:57:43 +0100 |
parents | ae821ac9ec74 |
children | 5fc630696dc7 |
files | scripts/plot/appearance/legend.m |
diffstat | 1 files changed, 17 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/legend.m Mon Nov 25 10:13:04 2019 -0800 +++ b/scripts/plot/appearance/legend.m Tue Nov 26 13:57:43 2019 +0100 @@ -182,7 +182,8 @@ if (isempty (hl)) - hl = axes ("tag", "legend", "handlevisibility", "off", ... + hl = axes ("parent", get (opts.axes_handles(1), "parent"), ... + "tag", "legend", "handlevisibility", "off", ... "ydir", "reverse", "position", [.5 .5 .3 .3], ... "fontsize", 0.9 * get (opts.axes_handles(1), "fontsize"), ... "clim", get (opts.axes_handles(1), "clim"), ... @@ -226,23 +227,24 @@ ## Listeners to foreign objects properties are stored for later ## deletion in "delfunction" setappdata (hl, "__listeners__", {}); - add_safe_listener (hl, ancestor (opts.axes_handles(1), "figure"), - "position", {@maybe_update_layout_cb, hl}); - add_safe_listener (hl, opts.axes_handles(1), - "position", {@maybe_update_layout_cb, hl}); - add_safe_listener (hl, opts.axes_handles(1), ... - "tightinset", ... + + hax = opts.axes_handles(1); + hf = ancestor (hax, "figure"); + + add_safe_listener (hl, hf, "colormap", ... + @() set (hl, "colormap", get (hax, "colormap"))); + add_safe_listener (hl, hf, "position", {@maybe_update_layout_cb, hl}); + + add_safe_listener (hl, hax, "position", {@maybe_update_layout_cb, hl}); + add_safe_listener (hl, hax, "tightinset", ... @(h) update_layout_cb (get (h, "__legend_handle__"))); - add_safe_listener (hl, opts.axes_handles(1), ... - "clim", @(hax) set (hl, "clim", get (hax, "clim"))); - add_safe_listener (hl, opts.axes_handles(1), ... - "colormap", ... + add_safe_listener (hl, hax, "clim", ... + @(hax) set (hl, "clim", get (hax, "clim"))); + add_safe_listener (hl, hax, "colormap", ... @(hax) set (hl, "colormap", get (hax, "colormap"))); - add_safe_listener (hl, opts.axes_handles(1), ... - "fontsize", ... + add_safe_listener (hl, hax, "fontsize", ... @(hax) set (hl, "fontsize", 0.9*get (hax, "fontsize"))); - add_safe_listener (hl, opts.axes_handles(1), ... - "children", {@legend_autoupdate_cb, hl}); + add_safe_listener (hl, hax, "children", {@legend_autoupdate_cb, hl}); ## Listeners to legend properties props = {"fontsize", "fontweight", "fontname", "interpreter", ...