# HG changeset patch # User Ben Abbott # Date 1316375754 14400 # Node ID da71f676e449a3be113ebdc570fed573d574538e # Parent 62e710cea7f1aa8dd2b53224523c11d2b18b020e 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. diff --git a/scripts/plot/contour.m b/scripts/plot/contour.m --- 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") + diff --git a/scripts/plot/private/__contour__.m b/scripts/plot/private/__contour__.m --- 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