# HG changeset patch # User Rik # Date 1375624949 25200 # Node ID 0a761f218d8dbfbe2a940b0581b897bec1d6f3e2 # Parent 0e34c475c956113cdc2f0f1c796d2746e660973c Fix contour plot axis to x-y data range, not axis ("tight"). * scripts/plot/private/__contour__.m: Remove axis ("tight"). Set axis range before adding patches so that axis limits aren't re-calculated for each patch. * scripts/plot/meshc.m, scripts/plot/surfc.m: Set xlimmode, ylimmode to manual. scripts/plot/private/__ezplot__.m: Remove FIXME comment and manually setting axis which was workaround for old behavior. diff --git a/scripts/plot/meshc.m b/scripts/plot/meshc.m --- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -74,7 +74,8 @@ set (htmp, "edgecolor", "flat"); if (! ishold ()) set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + "xgrid", "on", "ygrid", "on", "zgrid", "on", + "xlimmode", "manual", "ylimmode", "manual"); endif drawnow (); 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 @@ -140,9 +140,8 @@ addproperty ("fill", hg, "radio", "on|{off}", filled); - ## The properties zlevel and zlevelmode don't exist in matlab, but - ## allow the use of contourgroups with the contour3, meshc and surfc - ## functions. + ## The properties zlevel and zlevelmode don't exist in matlab, but allow the + ## use of contourgroups with the contour3, meshc, and surfc functions. if (isnumeric (zlevel)) addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", "manual"); addproperty ("zlevel", hg, "data", zlevel); @@ -183,8 +182,8 @@ addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); addproperty ("linewidth", hg, "linelinewidth", 0.5); - ## FIXME It would be good to hide this property which is just an undocumented - ## alias for linecolor + ## FIXME: It would be good to hide this property which is just an + ## undocumented alias for linecolor addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none"); addlistener (hg, "fill", @update_data); @@ -210,13 +209,18 @@ addlistener (hg, "edgecolor", @update_edgecolor); + ## Set axis before adding patches so that each new patch does not trigger + ## new axis calculation. No need if mode is already "manual". + if (all (strcmp (get (gca (), {"xlimmode", "ylimmode"}), "auto"))) + axis ([min(x1(:)) max(x1(:)) min(y1(:)) max(y1(:))]); + endif + add_patch_children (hg); - axis ("tight"); - - if (!isempty (opts)) + if (! isempty (opts)) set (hg, opts{:}); endif + endfunction function add_patch_children (hg) @@ -392,6 +396,7 @@ endfunction function update_zlevel (h, d) + z = get (h, "zlevel"); zmode = get (h, "zlevelmode"); kids = get (h, "children"); @@ -554,7 +559,7 @@ endfunction function lvl_eps = get_lvl_eps (lev) - ## FIXME -- is this the right thing to do for this tolerance? Should + ## 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)) diff --git a/scripts/plot/private/__ezplot__.m b/scripts/plot/private/__ezplot__.m --- a/scripts/plot/private/__ezplot__.m +++ b/scripts/plot/private/__ezplot__.m @@ -432,9 +432,6 @@ hax = newplot (hax); if (iscontour) [~, h] = feval (pltfunc, hax, X, Y, Z); - ## FIXME: Work around contour setting axis tight. - ## Fix should really be in __countour__. - axis (hax, domain); elseif (isplot && nargs == 2) h = zeros (length (XX), 1); hold_state = get (hax, "nextplot"); diff --git a/scripts/plot/surfc.m b/scripts/plot/surfc.m --- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -73,7 +73,8 @@ set (htmp, "facecolor", "flat"); if (! ishold ()) set (hax, "view", [-37.5, 30], - "xgrid", "on", "ygrid", "on", "zgrid", "on"); + "xgrid", "on", "ygrid", "on", "zgrid", "on", + "xlimmode", "manual", "ylimmode", "manual"); endif drawnow ();