def patch_is_interactive():
    """ Patch matplotlib function 'use' """
    matplotlib = sys.modules['matplotlib']

    def patched_is_interactive():
        return matplotlib.rcParams['interactive']

    matplotlib.real_is_interactive = matplotlib.is_interactive
    matplotlib.is_interactive = patched_is_interactive
Patch matplotlib function 'use'