Mercurial > hg > octave-nkf
changeset 18490:be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
* legend.m: When creating line object in legend, copy linewidth from plot
object. Restrict legend linewidth to a maximum of 5 to prevent overflowing
visual area. Add listener for linewidth on plot objects which updates legend.
author | Joachim Wiesemann <gnu@jwiesemann.com> |
---|---|
date | Tue, 14 Jan 2014 15:32:10 +0100 |
parents | 7c0db9c4e454 |
children | 1597281144e4 |
files | scripts/plot/appearance/legend.m |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/legend.m +++ b/scripts/plot/appearance/legend.m @@ -829,10 +829,11 @@ case "line" color = get (hplots(k), "color"); style = get (hplots(k), "linestyle"); + lwidth = min (get (hplots(k), "linewidth"), 5); if (! strcmp (style, "none")) l1 = line ("xdata", ([xoffset, xoffset + linelength] + xk * xstep) / lpos(3), "ydata", [1, 1] .* (lpos(4) - yoffset - yk * ystep) / lpos(4), - "color", color, "linestyle", style, + "color", color, "linestyle", style, "linewidth", lwidth, "marker", "none", "userdata", hplots(k)); hobjects(end+1) = l1; @@ -841,7 +842,7 @@ if (! strcmp (marker, "none")) l1 = line ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3), "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4), - "color", color, "linestyle", "none", + "color", color, "linestyle", "none", "linewidth", lwidth, "marker", marker, "markeredgecolor",get (hplots(k), "markeredgecolor"), "markerfacecolor",get (hplots(k), "markerfacecolor"), @@ -855,6 +856,8 @@ {@updateline, hlegend, linelength, false}); addlistener (hplots(k), "linestyle", {@updateline, hlegend, linelength, false}); + addlistener (hplots(k), "linewidth", + {@updateline, hlegend, linelength, false}); addlistener (hplots(k), "marker", {@updateline, hlegend, linelength, false}); addlistener (hplots(k), "markeredgecolor", @@ -1149,6 +1152,7 @@ if (ishandle (hplots(i)) && strcmp (get (hplots(i), "type"), "line")) dellistener (hplots(i), "color"); dellistener (hplots(i), "linestyle"); + dellistener (hplots(i), "linewidth"); dellistener (hplots(i), "marker"); dellistener (hplots(i), "markeredgecolor"); dellistener (hplots(i), "markerfacecolor"); @@ -1198,14 +1202,18 @@ if (! strcmp (linestyle, "none")) line ("xdata", xpos1, "ydata", ypos1, "color", get (h, "color"), - "linestyle", get (h, "linestyle"), "marker", "none", + "linestyle", get (h, "linestyle"), + "linewidth", min (get (h, "linewidth"), 5), + "marker", "none", "userdata", h, "parent", hlegend); endif if (! strcmp (marker, "none")) line ("xdata", xpos2, "ydata", ypos2, "color", get (h, "color"), "marker", marker, "markeredgecolor", get (h, "markeredgecolor"), "markerfacecolor", get (h, "markerfacecolor"), - "markersize", get (h, "markersize"), "linestyle", "none", + "markersize", get (h, "markersize"), + "linestyle", "none", + "linewidth", min (get (h, "linewidth"), 5), "userdata", h, "parent", hlegend); endif endif