From 260034754edc23f23cc9d3f874551b437f3e5b91 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 27 Jan 2012 14:02:21 -0500 Subject: [PATCH] Update plot_image.py's interpolation extraction for Matplotlib 0.91.2. I'd written it for v1.0.1, but the department server is still running 0.91.2, which only sets the interpolation dictionary for AxesImage instances (not for the class itself). --- src/plot_image/plot_image.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plot_image/plot_image.py b/src/plot_image/plot_image.py index 8c0a338..dd772a0 100755 --- a/src/plot_image/plot_image.py +++ b/src/plot_image/plot_image.py @@ -174,6 +174,17 @@ def plot(X, Y, Z, full=False, title=None, contours=None, interpolation=None, return fig +def get_possible_interpolations(): + try: # Matplotlib v1.0.1 + return sorted(matplotlib.image.AxesImage._interpd.keys()) + except AttributeError: + try: # Matplotlib v0.91.2 + return sorted(matplotlib.image.AxesImage(None)._interpd.keys()) + except AttributeError: + # give up ;) + pass + return ['nearest'] + def test(): import doctest results = doctest.testmod() @@ -231,7 +242,7 @@ def main(argv=None): help='Title (%default)') p.add_option('--test', dest='test', action='store_true', help='Run internal tests and exit.') - interpolations = sorted(matplotlib.image.AxesImage._interpd.keys()) + interpolations = get_possible_interpolations() p.add_option('--interpolation', dest='interpolation', default='nearest', help=('Interpolation scheme (for false color images) from %s ' '(%%default)') % ', '.join(interpolations)) -- 2.26.2