# HG changeset patch # User John W. Eaton # Date 1267073672 18000 # Node ID f074aa6b2c804af4485815ba61df04b95831dd0e # Parent 7ed1f2e831bafb4364070da82f5cd109f1a8a813 __contour__: don't fail if zlevel is a vector with all the same values diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,9 @@ +2010-02-24 John W. Eaton + + * plot/private/__contour__.m (get_lvl_eps): New function. + Handle case of single level value. Use sqrt (eps) instead of 1e-6. + (update_text, add_patch_children): Use it. + 2010-02-19 Rik * optimization/fzero.m: Add test for discontinuity at the end. 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 @@ -229,11 +229,8 @@ endif if (strcmpi (filled, "on")) - if (diff (lev) < 10*eps) - lvl_eps = 1e-6; - else - lvl_eps = min (diff (lev)) / 1000.0; - endif + + lvl_eps = get_lvl_eps (lev); ## Decode contourc output format. i1 = 1; @@ -483,11 +480,7 @@ elseif (strcmpi (get (h, "textstepmode"), "manual")) lev = get (h, "levellist"); - if (diff (lev) < 10*eps) - lvl_eps = 1e-6; - else - lvl_eps = min (abs (diff (lev))) / 1000.0; - endif + lvl_eps = get_lvl_eps (lev); stp = get (h, "textstep"); t = [0, floor(cumsum(diff (lev)) / (abs(stp) - lvl_eps))]; @@ -515,3 +508,19 @@ recursive = false; endfunction + +function lvl_eps = get_lvl_eps (lev) + ## FIXME -- is this the right thing to do for this tolerance? Should + ## it be an absolute or relative tolerance, or switch from one to the + ## other depending on the value of lev? + if (isscalar (lev)) + lvl_eps = abs (lev) * sqrt (eps); + else + tmp = min (abs (diff (lev))); + if (tmp < 10*eps) + lvl_eps = sqrt (eps); + else + lvl_eps = tmp / 1000.0; + endif + endif +endfunction