def background():
    (fig, ax) = plt.subplots()
    plt.show(block=False)
    (ln,) = ax.plot(range(5))
    thread_start_time = start_time = time.monotonic()
    fig.canvas.flush_events()
    for j in range(5):
        print(f'starting block {j} at Δt {(time.monotonic() - start_time):.3f} (expected ~{j})')
        ln.set_color(f'C{j}')
        ax.set_title(f'cycle {j}')
        fig.set_size_inches((1 + j), (1 + j))
        fig.canvas.draw_idle()
        print(f"line should now be color 'C{j}'")
        time.sleep(1)
    plt.close(fig)
    print('figure is now closed, take a 1s nap')
    time.sleep(1)
    fig2 = plt.figure()
    fig2.show()
    print('New figure!')
    start_time = time.monotonic()
    for j in range(4):
        time.sleep(1)
        fig2.canvas.manager.full_screen_toggle()
        fig2.canvas.manager.set_window_title(f'toggled {j}')
        print(f'toggled Δt {(time.monotonic() - start_time):.3f} (expected ~{(j + 1)})')
    (fig3, _) = plt.subplots(3, 1)
    fig3.show()
    print('figure is small again and there are two figures.')
    print('take 1s nap')
    time.sleep(1)
    plt.close('all')
    print(f'all figures should be closedapp will exit in {(12 - (time.monotonic() - thread_start_time))}s on hit quit.')
def background():
    (fig, ax) = plt.subplots()
    plt.show(block=False)
    (ln,) = ax.plot(range(5))
    thread_start_time = start_time = time.monotonic()
    fig.canvas.flush_events()
    for j in range(5):
        print(f'starting block {j} at Δt {(time.monotonic() - start_time):.3f} (expected ~{j})')
        ln.set_color(f'C{j}')
        ax.set_title(f'cycle {j}')
        fig.set_size_inches((1 + j), (1 + j))
        fig.canvas.draw_idle()
        print(f"line should now be color 'C{j}'")
        time.sleep(1)
    plt.close(fig)
    print('figure is now closed, take a 1s nap')
    time.sleep(1)
    fig2 = plt.figure()
    fig2.show()
    print('New figure!')
    start_time = time.monotonic()
    for j in range(4):
        time.sleep(1)
        fig2.canvas.manager.full_screen_toggle()
        fig2.canvas.manager.set_window_title(f'toggled {j}')
        print(f'toggled Δt {(time.monotonic() - start_time):.3f} (expected ~{(j + 1)})')
    (fig3, _) = plt.subplots(3, 1)
    fig3.show()
    print('figure is small again and there are two figures.')
    print('take 1s nap')
    time.sleep(1)
    plt.close('all')
    print(f'all figures should be closedapp will exit in {(12 - (time.monotonic() - thread_start_time))}s on hit quit.')