@@ -90,7 +90,6 @@ def update(frame):
90
90
delta = np .pi / 2
91
91
92
92
scat = ax .scatter (np .sin (a * t [0 ] + delta ), np .sin (b * t [0 ]), c = "b" , s = 2 )
93
- ax .grid ()
94
93
ax .set_xlim (- 1.5 , 1.5 )
95
94
ax .set_ylim (- 1.5 , 1.5 )
96
95
@@ -152,28 +151,22 @@ def update(frame):
152
151
# :class:`~matplotlib.animation.ArtistAnimation`
153
152
# ----------------------------------------------
154
153
#
155
- # On the other hand, :class:`~matplotlib.animation.ArtistAnimation` can be used
156
- # to generate animations if we have data on various different artists. This
157
- # list of artists is then converted frame by frame into an animation.
158
-
154
+ # :class:`~matplotlib.animation.ArtistAnimation` can be used
155
+ # to generate animations if there is data stored on various different artists.
156
+ # This list of artists is then converted frame by frame into an animation. For
157
+ # example, when we use `Axes.bar` to plot a bar-chart, it creates a number of
158
+ # artists for each of the bar and error bars. To update the plot, one would
159
+ # need to update each of the bars from the container individually and redraw
160
+ # them. Instead, `.animation.ArtistAnimation` can be used to plot each frame
161
+ # individually and then stitched together to form an animation.
159
162
160
- def f (x , y , mean , cov ):
161
- dev_x = x - mean
162
- dev_y = y - mean
163
- maha = - 0.5 * (((x - mean )/ cov )** 2 + ((y - mean )/ cov )** 2 )
164
- return (1 / (np .pi * cov )) * np .exp (maha )
165
163
166
164
fig , ax = plt .subplots ()
167
-
168
- x , y = np .meshgrid (np .arange (- 1 , 1 , 0.01 ), np .arange (- 1 , 1 , 0.01 ))
169
- mean = 0
170
- cov = 0.1
171
- data = f (x , y , mean , cov )
172
- aximg = ax .imshow (data )
165
+ data = np .array ([10 , 20 , 20 , 30 ])
166
+ x = [1 , 2 , 3 , 4 ]
173
167
174
168
artists = [
175
- [ax .imshow (f (x , y , mean , 0.01 * frame + 1e-6 ))]
176
- for frame in range (120 )
169
+ list (ax .bar (x , data + i , color = 'b' )) for i in range (10 )
177
170
]
178
171
179
172
ani = animation .ArtistAnimation (fig = fig , artists = artists , interval = 100 )
0 commit comments