# HG changeset patch # User Pantxo Diribarne # Date 1393369009 -3600 # Node ID bf0d2e51c8f02636a25f7b14500d62619871b627 # Parent c9ace0567f1343a2dea0a4257711725895900709 axis.m: make 'tight' embrace whole images (bug #36594). * axis.m (__get_tight_lims__): extend image data limits by one pixel. * image.m: remove duplicate code and call "axis image" when there's no other child in the axes. diff -r c9ace0567f13 -r bf0d2e51c8f0 scripts/image/image.m --- a/scripts/image/image.m Sat Feb 22 12:22:34 2014 -0800 +++ b/scripts/image/image.m Tue Feb 25 23:56:49 2014 +0100 @@ -183,28 +183,9 @@ ## Set axis properties for new images if (! isempty (img)) - px = __image_pixel_size__ (h); - - if (xdata(2) < xdata(1)) - xdata = fliplr (xdata); - elseif (xdata(2) == xdata(1)) - xdata = xdata(1) + [0, columns(img)-1]; + if (isscalar (get (hax, "children"))) + axis (hax, "image") endif - if (ydata(2) < ydata(1)) - ydata = fliplr (ydata); - elseif (ydata(2) == ydata(1)) - ydata = ydata(1) + [0, rows(img)-1]; - endif - xlim = xdata + [-px(1), px(1)]; - ylim = ydata + [-px(2), px(2)]; - - ## FIXME -- how can we do this and also get the {x,y}limmode - ## properties to remain "auto"? I suppose this adjustment should - ## happen automatically in axes::update_axis_limits instead of - ## explicitly setting the values here. But then what information is - ## available to axes::update_axis_limits to determine that the - ## adjustment is necessary? - set (hax, "xlim", xlim, "ylim", ylim); if (ndims (img) == 3) if (isinteger (img)) diff -r c9ace0567f13 -r bf0d2e51c8f0 scripts/plot/appearance/axis.m --- a/scripts/plot/appearance/axis.m Sat Feb 22 12:22:34 2014 -0800 +++ b/scripts/plot/appearance/axis.m Tue Feb 25 23:56:49 2014 +0100 @@ -332,10 +332,24 @@ lims = get (ca, strcat (ax, "lim")); else data = get (kids, strcat (ax, "data")); + types = get (kids, "type"); + scale = get (ca, strcat (ax, "scale")); if (! iscell (data)) data = {data}; endif + + ## Extend image data one pixel + idx = strcmp (types, "image"); + if (! isempty (idx) && (ax == "x" || ax == "y")) + imdata = data(idx); + px = arrayfun (@__image_pixel_size__, kids(idx), "uniformoutput", false); + ipx = ifelse (ax == "x", 1, 2); + imdata = cellfun (@(x,dx) [(min (x) - dx(ipx)), (max (x) + dx(ipx))], + imdata, px, "uniformoutput", false); + data(idx) = imdata; + endif + if (strcmp (scale, "log")) tmp = data; data = cellfun (@(x) x(x>0), tmp, "uniformoutput", false);