diff options
| author | zhang <zch921005@126.com> | 2022-05-21 14:23:49 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2022-05-21 14:23:49 +0800 |
| commit | 678fab50280b647d95213a9695d07c49542696f2 (patch) | |
| tree | 74ca60de14311a8a2ff58dbf82d9b7574c9cd3ef /vis | |
| parent | 2180c68999eb8dc0c7bcec015b2703f5b8b20223 (diff) | |
0521
Diffstat (limited to 'vis')
| -rw-r--r-- | vis/animation/text_animation.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/vis/animation/text_animation.py b/vis/animation/text_animation.py new file mode 100644 index 0000000..1558d19 --- /dev/null +++ b/vis/animation/text_animation.py @@ -0,0 +1,18 @@ +from matplotlib import pyplot as plt, animation + +plt.rcParams["figure.figsize"] = [7.50, 3.50] +plt.rcParams["figure.autolayout"] = True +fig, ax = plt.subplots() +ax.set(xlim=(-1, 1), ylim=(-1, 1)) +string = 'Hello, how are you doing?' +label = ax.text(0, 0, string[0], ha='center', va='center', fontsize=20, color="Red") + + +def animate(i): + label.set_text(string[:i + 1]) + + +anim = animation.FuncAnimation( + fig, animate, interval=100, frames=len(string)) +ax.axis('off') +plt.show() |
