# HG changeset patch # User Rik # Date 1394995451 25200 # Node ID 3a1a4d587c4e4f117c3d22c72cd66e41f672d714 # Parent 3dac2a233386083a3506c361261ce977735831b1 legend.m: Correctly create legend for scatter plots (bug #33463). * legend.m: Handle special case of scatter plot which uses patch objects, but only the marker properties rather than the regular facecolor and edgecolor properties. diff -r 3dac2a233386 -r 3a1a4d587c4e scripts/plot/appearance/legend.m --- a/scripts/plot/appearance/legend.m Sat Mar 15 19:22:55 2014 -0700 +++ b/scripts/plot/appearance/legend.m Sun Mar 16 11:44:11 2014 -0700 @@ -879,13 +879,24 @@ xoffset + xk * xstep) / lpos(3), "ydata", (lpos(4) - yoffset - [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4), - "facecolor", facecolor, "edgecolor", edgecolor, - "cdata", cdata, "userdata", hplots(k)); - hobjects(end+1) = p1; - ## Copy clim from axes so that colors work out. - set (hlegend, "clim", get (ca(1), "clim")); + "facecolor", facecolor, "edgecolor", edgecolor, + "cdata", cdata, "userdata", hplots(k)); + else + ## non-standard patch only making use of marker styles + ## such as scatter plot. + p1 = patch ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3), + "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4), + "marker", get (hplots(k), "marker"), + "markeredgecolor",get (hplots(k),"markeredgecolor"), + "markerfacecolor",get (hplots(k),"markerfacecolor"), + "markersize", min (get (hplots(k),"markersize"),10), + "cdata", cdata, "userdata", hplots(k)); endif - ## FIXME: Probably need listeners, as for line objects + hobjects(end+1) = p1; + ## Copy clim from axes so that colors work out. + set (hlegend, "clim", get (ca(1), "clim")); + + ## FIXME: Need listeners, as for line objects. ## Changing clim, for example, won't update colors case "surface" @@ -897,11 +908,11 @@ xoffset + xk * xstep) / lpos(3), "ydata", (lpos(4) - yoffset - [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4), - "facecolor", facecolor, "edgecolor", edgecolor, - "cdata", cdata, "userdata", hplots(k)); + "facecolor", facecolor, "edgecolor", edgecolor, + "cdata", cdata, "userdata", hplots(k)); hobjects(end+1) = p1; endif - ## FIXME: Probably need listeners, as for line objects + ## FIXME: Need listeners, as for line objects. endswitch