|
49 | 49 | # *func* that modifies the data plotted on the figure. It uses the *frames*
|
50 | 50 | # parameter to determine the length of the animation. The *interval* parameter
|
51 | 51 | # is used to determine time in milliseconds between drawing of two frames.
|
52 |
| -# Animating using `.FuncAnimation` would usually follow the following |
53 |
| -# structure: |
54 |
| -# |
55 |
| -# - Plot the initial figure, including all the required artists. Save all the |
56 |
| -# artists in variables so that they can be updated later on during the |
57 |
| -# animation. |
58 |
| -# - Create an animation function that updates the data in each artist to |
59 |
| -# generate the new frame at each function call. |
60 |
| -# - Create a `.FuncAnimation` object with the `.Figure` and the animation |
61 |
| -# function, along with the keyword arguments that determine the animation |
62 |
| -# properties. |
63 |
| -# - Use `.animation.Animation.save` or `.pyplot.show` to save or show the |
64 |
| -# animation. |
65 |
| -# |
66 |
| -# The update function uses the ``set_*`` function for different artists to |
67 |
| -# modify the data. The following table shows a few plotting methods, the artist |
68 |
| -# types they return and some methods that can be used to update them. |
| 52 | +# Animating using `.FuncAnimation` typically requires these steps: |
| 53 | +# |
| 54 | +# 1) Plot the initial figure as you would in a static plot. Save all the created |
| 55 | +# artists, which are returned by the plot functions, in variables so that you can |
| 56 | +# access and modify them later in the animation function. |
| 57 | +# 2) Create an animation function that updates the artists for a given frame. |
| 58 | +# Typically, this calls ``set_*`` methods of the artists. |
| 59 | +# 3) Create a `.FuncAnimation`, passing the `.Figure` and the animation function. |
| 60 | +# 4) Save or show the animation using one of the following methods: |
| 61 | +# |
| 62 | +# - `.pyplot.show` to show the animation in a window |
| 63 | +# - `.Animation.to_html5_video` to create a HTML ``<video>`` tag |
| 64 | +# - `.Animation.to_jshtml` to create HTML code with interactive JavaScript animation |
| 65 | +# controls |
| 66 | +# - `.Animation.save` to save the animation to a file |
| 67 | +# |
| 68 | +# The following table shows a few plotting methods, the artists they return and some |
| 69 | +# commonly used ``set_*`` methods that update the underlying data. While updating data |
| 70 | +# is the most common operation in animations, you can also update other aspects such as |
| 71 | +# color or text position. |
69 | 72 | #
|
70 | 73 | # ======================================== ============================= ===========================
|
71 |
| -# Plotting method Artist Set method |
| 74 | +# Plotting method Artist Data set methods |
72 | 75 | # ======================================== ============================= ===========================
|
73 |
| -# `.Axes.plot` `.lines.Line2D` `~.lines.Line2D.set_data` |
| 76 | +# `.Axes.plot` `.lines.Line2D` `~.Line2D.set_data`, |
| 77 | +# `~.Line2D.set_xdata`, |
| 78 | +# `~.Line2D.set_ydata` |
74 | 79 | # `.Axes.scatter` `.collections.PathCollection` `~.collections.\
|
75 | 80 | # PathCollection.set_offsets`
|
76 | 81 | # `.Axes.imshow` `.image.AxesImage` ``AxesImage.set_data``
|
|
88 | 93 | # `~.Ellipse.set_center`,
|
89 | 94 | # `~.Ellipse.set_height`,
|
90 | 95 | # `~.Ellipse.set_width`
|
| 96 | +# `.Axes.set_title`, `.Axes.text` `.text.Text` `~.Text.set_text` |
91 | 97 | # ======================================== ============================= ===========================
|
92 | 98 | #
|
93 | 99 | # Covering the set methods for all types of artists is beyond the scope of this
|
|
0 commit comments