Mercurial > hg > octave-nkf
changeset 18670:3a1a4d587c4e
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.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 16 Mar 2014 11:44:11 -0700 |
parents | 3dac2a233386 |
children | 875f4510d6dc |
files | scripts/plot/appearance/legend.m |
diffstat | 1 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/legend.m +++ b/scripts/plot/appearance/legend.m @@ -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