# HG changeset patch # User Joachim Wiesemann # Date 1389709930 -3600 # Node ID be3702a2eb8aa1aae68677e05ef7539191e9f22e # Parent 7c0db9c4e4545aa188bcb1b3703286ccfc5b250c 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. diff -r 7c0db9c4e454 -r be3702a2eb8a scripts/plot/appearance/legend.m --- a/scripts/plot/appearance/legend.m Sun Feb 02 20:26:28 2014 -0800 +++ b/scripts/plot/appearance/legend.m Tue Jan 14 15:32:10 2014 +0100 @@ -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