Example #1
0
def test_save_animation_smoketest(tmpdir, writer, extension):
    try:
        # for ImageMagick the rcparams must be patched to account for
        # 'convert' being a built in MS tool, not the imagemagick
        # tool.
        writer._init_from_registry()
    except AttributeError:
        pass
    if not animation.writers.is_available(writer):
        skip("writer '%s' not available on this system" % writer)
    fig, ax = plt.subplots()
    line, = ax.plot([], [])

    ax.set_xlim(0, 10)
    ax.set_ylim(-1, 1)

    def init():
        line.set_data([], [])
        return line,

    def animate(i):
        x = np.linspace(0, 10, 100)
        y = np.sin(x + i)
        line.set_data(x, y)
        return line,

    # Use temporary directory for the file-based writers, which produce a file
    # per frame with known names.
    with tmpdir.as_cwd():
        anim = animation.FuncAnimation(fig, animate, init_func=init, frames=5)
        try:
            anim.save('movie.' + extension, fps=30, writer=writer, bitrate=500)
        except UnicodeDecodeError:
            xfail("There can be errors in the numpy import stack, "
                  "see issues #1891 and #2679")
Example #2
0
def test_pdflatex():
    import os
    if os.environ.get('APPVEYOR', False):
        from matplotlib.testing import xfail
        xfail("pdflatex test does not work on appveyor due "
              "to missing latex fonts")
    if not check_for('pdflatex'):
        raise SkipTest('pdflatex + pgf is required')

    rc_pdflatex = {'font.family': 'serif',
                   'pgf.rcfonts': False,
                   'pgf.texsystem': 'pdflatex',
                   'pgf.preamble': ['\\usepackage[utf8x]{inputenc}',
                                    '\\usepackage[T1]{fontenc}']}
    mpl.rcParams.update(rc_pdflatex)
    create_figure()
    compare_figure('pgf_pdflatex.pdf', tol=0)
Example #3
0
def test_pdflatex():
    import os
    if os.environ.get('APPVEYOR', False):
        from matplotlib.testing import xfail
        xfail("pdflatex test does not work on appveyor due "
              "to missing latex fonts")

    rc_pdflatex = {
        'font.family':
        'serif',
        'pgf.rcfonts':
        False,
        'pgf.texsystem':
        'pdflatex',
        'pgf.preamble':
        ['\\usepackage[utf8x]{inputenc}', '\\usepackage[T1]{fontenc}']
    }
    mpl.rcParams.update(rc_pdflatex)
    create_figure()
    compare_figure('pgf_pdflatex.pdf', tol=0)
Example #4
0
def test_save_animation_smoketest(writer, extension):
    try:
        # for ImageMagick the rcparams must be patched to account for
        # 'convert' being a built in MS tool, not the imagemagick
        # tool.
        writer._init_from_registry()
    except AttributeError:
        pass
    if not animation.writers.is_available(writer):
        skip("writer '%s' not available on this system" % writer)
    fig, ax = plt.subplots()
    line, = ax.plot([], [])

    ax.set_xlim(0, 10)
    ax.set_ylim(-1, 1)

    def init():
        line.set_data([], [])
        return line,

    def animate(i):
        x = np.linspace(0, 10, 100)
        y = np.sin(x + i)
        line.set_data(x, y)
        return line,

    # Use NamedTemporaryFile: will be automatically deleted
    F = tempfile.NamedTemporaryFile(suffix='.' + extension)
    F.close()
    anim = animation.FuncAnimation(fig, animate, init_func=init, frames=5)
    try:
        anim.save(F.name, fps=30, writer=writer, bitrate=500)
    except UnicodeDecodeError:
        xfail("There can be errors in the numpy import stack, "
              "see issues #1891 and #2679")
    finally:
        try:
            os.remove(F.name)
        except Exception:
            pass