diff scripts/plot/appearance/axis.m @ 18592:bf0d2e51c8f0 stable

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.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 25 Feb 2014 23:56:49 +0100
parents df8e5e3a0f67
children 89a8a90ac850 01aa90ece9a4
line wrap: on
line diff
--- a/scripts/plot/appearance/axis.m
+++ b/scripts/plot/appearance/axis.m
@@ -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);