FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/examples/animation/basic_example.py at master · jmg6yo/matplotlib.github.com · GitHub
jmg6yo
/
matplotlib.github.com
Public
forked from
matplotlib/matplotlib.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
examples
/
animation
/
basic_example.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (35 loc) · 1.17 KB
Breadcrumbs
matplotlib.github.com
/
examples
/
animation
/
basic_example.py
Copy path
File metadata and controls
46 lines (35 loc) · 1.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
=========================
Simple animation examples
=========================
This example contains two animations. The first is a random walk plot. The
second is an image animation.
"""
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
import
matplotlib
.
animation
as
animation
def
update_line
(
num
,
data
,
line
):
line
.
set_data
(
data
[..., :
num
])
return
line
,
fig1
=
plt
.
figure
()
data
=
np
.
random
.
rand
(
2
,
25
)
l
,
=
plt
.
plot
([], [],
'r-'
)
plt
.
xlim
(
0
,
1
)
plt
.
ylim
(
0
,
1
)
plt
.
xlabel
(
'x'
)
plt
.
title
(
'test'
)
line_ani
=
animation
.
FuncAnimation
(
fig1
,
update_line
,
25
,
fargs
=
(
data
,
l
),
interval
=
50
,
blit
=
True
)
# To save the animation, use the command: line_ani.save('lines.mp4')
fig2
=
plt
.
figure
()
x
=
np
.
arange
(
-
9
,
10
)
y
=
np
.
arange
(
-
9
,
10
).
reshape
(
-
1
,
1
)
base
=
np
.
hypot
(
x
,
y
)
ims
=
[]
for
add
in
np
.
arange
(
15
):
ims
.
append
((
plt
.
pcolor
(
x
,
y
,
base
+
add
,
norm
=
plt
.
Normalize
(
0
,
30
)),))
im_ani
=
animation
.
ArtistAnimation
(
fig2
,
ims
,
interval
=
50
,
repeat_delay
=
3000
,
blit
=
True
)
# To save this second animation with some metadata, use the following command:
# im_ani.save('im.mp4', metadata={'artist':'Guido'})
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL