Esempio n. 1
0
def test_image():
    # Prior to v1.4.0 the Image would cache data which was not picklable
    # once it had been drawn.
    from matplotlib.backends.backend_agg import new_figure_manager
    manager = new_figure_manager(1000)
    fig = manager.canvas.figure
    ax = fig.add_subplot(1, 1, 1)
    ax.imshow(np.arange(12).reshape(3, 4))
    manager.canvas.draw()
    pickle.dump(fig, BytesIO())
Esempio n. 2
0
def test_image():
    # Prior to v1.4.0 the Image would cache data which was not picklable
    # once it had been drawn.
    from matplotlib.backends.backend_agg import new_figure_manager
    manager = new_figure_manager(1000)
    fig = manager.canvas.figure
    ax = fig.add_subplot(1, 1, 1)
    ax.imshow(np.arange(12).reshape(3, 4))
    manager.canvas.draw()
    pickle.dump(fig, BytesIO())
Esempio n. 3
0
def test_grid():
    from matplotlib.backends.backend_agg import new_figure_manager
    manager = new_figure_manager(1000)
    fig = manager.canvas.figure
    ax = fig.add_subplot(1, 1, 1)
    ax.grid()
    # Drawing the grid triggers instance methods to be attached
    # to the Line2D object (_lineFunc).
    manager.canvas.draw()

    pickle.dump(ax, BytesIO())
Esempio n. 4
0
def test_grid():
    from matplotlib.backends.backend_agg import new_figure_manager
    manager = new_figure_manager(1000)
    fig = manager.canvas.figure
    ax = fig.add_subplot(1, 1, 1)
    ax.grid()
    # Drawing the grid triggers instance methods to be attached
    # to the Line2D object (_lineFunc).
    manager.canvas.draw()

    pickle.dump(ax, BytesIO())
Esempio n. 5
0
import numpy as np
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import new_figure_manager


def f(t):
    return np.exp(-t) * np.cos(2 * np.pi * t)


def graph(fig):
    t1 = np.arange(0.0, 5.0, 0.1)
    t2 = np.arange(0.0, 5.0, 0.02)
    ax = fig.add_subplot(1, 1, 1)
    ax.plot(t1, f(t1), 'bo', t2, f(t2), 'k')


fig = Figure()
graph(fig)

manager = new_figure_manager(1, dpi=72)
manager.canvas.figure = fig
fig.set_canvas(manager.canvas)
fig.savefig("dist/no-pyplot.png")
Esempio n. 6
0
 def get_figure_manager(self, fignum):
     return new_figure_manager(fignum)