@@ -31,6 +31,7 @@ class _AxesImageBase(martist.Artist, cm.ScalarMappable):
3131 zorder = 0
3232 # map interpolation strings to module constants
3333 _interpd = {
34+ 'none' : _image .NEAREST , # fall back to nearest when not supported
3435 'nearest' : _image .NEAREST ,
3536 'bilinear' : _image .BILINEAR ,
3637 'bicubic' : _image .BICUBIC ,
@@ -446,10 +447,15 @@ def set_interpolation(self, s):
446447 """
447448 Set the interpolation method the image uses when resizing.
448449
450+ if None, use a value from rc setting. If 'none', the image is
451+ shown as is without interpolating. 'none' is only supported in
452+ agg, ps and pdf backends and will fall back to 'nearest' mode
453+ for other backends.
454+
449455 ACCEPTS: ['nearest' | 'bilinear' | 'bicubic' | 'spline16' |
450456 'spline36' | 'hanning' | 'hamming' | 'hermite' | 'kaiser' |
451457 'quadric' | 'catrom' | 'gaussian' | 'bessel' | 'mitchell' |
452- 'sinc' | 'lanczos' | ]
458+ 'sinc' | 'lanczos' | 'none' | ]
453459
454460 """
455461 if s is None : s = rcParams ['image.interpolation' ]
@@ -610,10 +616,13 @@ def _check_unsampled_image(self, renderer):
610616 """
611617 return True if the image is better to be drawn unsampled.
612618 """
613- if renderer .option_scale_image () and self .get_interpolation () == "nearest" :
614- return True
615- else :
616- return False
619+ if self .get_interpolation () == "none" :
620+ if renderer .option_scale_image ():
621+ return True
622+ else :
623+ warnings .warn ("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % (str (type (renderer ))))
624+
625+ return False
617626
618627 def set_extent (self , extent ):
619628 """
0 commit comments