Mercurial > hg > octave-nkf
comparison scripts/plot/legend.m @ 17540:b7aa1d726bcc
legend.m: Add support for surface objects.
* scripts/plot/legend.m: Use a colored patch set to the mid-point of caxis() to
represent a surface in the legend.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 02 Oct 2013 21:58:56 -0700 |
parents | b29c8a067c11 |
children | 225ec9a0222a |
comparison
equal
deleted
inserted
replaced
17539:485aeffc0c22 | 17540:b7aa1d726bcc |
---|---|
880 "cdata", cdata, "userdata", hplots(k)); | 880 "cdata", cdata, "userdata", hplots(k)); |
881 hobjects(end+1) = p1; | 881 hobjects(end+1) = p1; |
882 endif | 882 endif |
883 | 883 |
884 case "surface" | 884 case "surface" |
885 ## FIXME: Would be nice to do something here | 885 facecolor = get (hplots(k), "facecolor"); |
886 edgecolor = get (hplots(k), "edgecolor"); | |
887 cdata = sum (caxis ()) / 2; | |
888 if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none")) | |
889 p1 = patch ("xdata", ([0, linelength, linelength, 0] + | |
890 xoffset + xk * xstep) / lpos(3), | |
891 "ydata", (lpos(4) - yoffset - | |
892 [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4), | |
893 "facecolor", facecolor, "edgecolor", edgecolor, | |
894 "cdata", cdata, "userdata", hplots(k)); | |
895 hobjects(end+1) = p1; | |
896 endif | |
886 | 897 |
887 endswitch | 898 endswitch |
888 | 899 |
889 set (texthandle(k), "position", | 900 set (texthandle(k), "position", |
890 [(txoffset + xk * xstep) / lpos(3), ... | 901 [(txoffset + xk * xstep) / lpos(3), ... |
1552 %! legend (option); | 1563 %! legend (option); |
1553 | 1564 |
1554 %!demo % bug 39697 | 1565 %!demo % bug 39697 |
1555 %! clf; | 1566 %! clf; |
1556 %! plot (1:10); | 1567 %! plot (1:10); |
1557 %! legend ("Legend Text"); | 1568 %! legend ('Legend Text'); |
1558 %! title ({"Multi-line", "titles", "are a", "problem"}); | 1569 %! title ({'Multi-line', 'titles', 'are a', 'problem'}); |
1570 | |
1571 %!demo | |
1572 %! clf; | |
1573 %! colormap (cool (64)); | |
1574 %! surf (peaks ()); | |
1575 %! legend ('peaks()') | |
1576 %! title ('legend() works for surface objects too'); | |
1559 | 1577 |
1560 %!test | 1578 %!test |
1561 %! toolkit = graphics_toolkit ("gnuplot"); | 1579 %! toolkit = graphics_toolkit ("gnuplot"); |
1562 %! h = figure ("visible", "off"); | 1580 %! h = figure ("visible", "off"); |
1563 %! unwind_protect | 1581 %! unwind_protect |