0

In this example, the animation appears to execute in my browser. That would be extremely helpful for me since I work on dynamic experiments. Can someone explain how this is animation was done, and can I create an html file and email it to a colleague so he can watch the animation execute in a browser on his computer. Also, can a play / pause button be installed, and possibly a pause at a specified time to highlight a specific aspect of the data.

Based on the comments, I'll change the question. How can I modify the following code to store the animation in a file (avi, gif).

import pyformulas as pf
import matplotlib.pyplot as plt
import numpy as np
import time

fig = plt.figure()

canvas = np.zeros((480, 640))
screen = pf.screen(canvas, 'Sinusoid')

start = time.time()
n = 34
while n < 120:
    n = n + 1
    now = time.time() - start

    x = np.linspace(now-2, now, 100)
    y = np.sin(2*np.pi*x) + np.sin(3*np.pi*x)
    plt.xlim(now-2, now+1)
    plt.ylim(-3, 3)
    plt.plot(x, y, c='black')

    # If we haven't already shown or saved the plot, then we need to draw the figure first...
    fig.canvas.draw()

    image = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
    image = image.reshape(fig.canvas.get_width_height()[::-1] + (3,))

    screen.update(image)

# screen.close()
input("Press Enter to close...")
martineau
  • 119,623
  • 25
  • 170
  • 301
John
  • 525
  • 5
  • 16
  • 1
    It's an animated GIF Image - https://en.wikipedia.org/wiki/GIF – Kingsley Jul 23 '19 at 00:52
  • Most GUI libraries can help you with this. But everybody works faster in a field they have experience before. I would jump into Pygame to record or display it. – Rockybilly Jul 23 '19 at 00:55
  • Maybe I just need to write an avi file that I can email. Putting it in html is probably overkill for show/tell. – John Jul 23 '19 at 01:02

0 Answers0