Mercurial > hg > octave-nkf
changeset 13156:da71f676e449 stable
Fix bug #34282. Fill holes in contours with the background colour
* scripts/plot/private/__contour__.m: Properly fill holes in contours.
* scripts/plot/contour.m: Add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 18 Sep 2011 15:55:54 -0400 |
parents | 62e710cea7f1 |
children | 6abc581bf2c9 |
files | scripts/plot/contour.m scripts/plot/private/__contour__.m |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -71,11 +71,22 @@ endfunction %!demo +%! clf () %! [x, y, z] = peaks (); %! contour (x, y, z); %!demo +%! clf () %! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64)); %! [X, Y] = pol2cart (theta, r); %! Z = sin(2*theta).*(1-r); %! contour(X, Y, abs(Z), 10) + +%!demo +%! clf () +%! x = linspace (-2, 2); +%! [x, y] = meshgrid (x); +%! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2+1); +%! contourf (x, y, z, [0.4, 0.4]) +%! title ("The hole should be filled with the background color") +
--- a/scripts/plot/private/__contour__.m +++ b/scripts/plot/private/__contour__.m @@ -319,10 +319,18 @@ else ## Special case unclosed contours endif + if (isnan(cont_lev(idx))) + fc = get (ca, "color"); + if (strcmp (fc, "none")) + fc = get (ancestor (ca, "figure"), "color"); + endif + else + fc = "flat"; + endif h = [h; __go_patch__(ca, "xdata", ctmp(1, :)(:), "ydata", ctmp(2, :)(:), "vertices", ctmp.', "faces", 1:(cont_len(idx)-1), "facevertexcdata", cont_lev(idx), - "facecolor", "flat", "cdata", cont_lev(idx), + "facecolor", fc, "cdata", cont_lev(idx), "edgecolor", lc, "linestyle", ls, "linewidth", lw, "parent", hg)]; endfor