Skip to content

Commit 4ae703d

Browse files
author
Mofan Zhou
committedSep 5, 2016
matplotlib update
1 parent f999c91 commit 4ae703d

6 files changed

+58
-7
lines changed
 

‎matplotlibTUT/plt14_3d.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
Please note, this script is for python3+.
99
If you are using python2+, please modify it accordingly.
10-
Tutorial page:
10+
Tutorial reference:
1111
http://www.python-course.eu/matplotlib_multiple_figures.php
1212
"""
1313

@@ -25,7 +25,7 @@
2525
# height value
2626
Z = np.sin(R)
2727

28-
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.cm.hot)
28+
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap('rainbow'))
2929
"""
3030
============= ================================================
3131
Argument Description
@@ -44,7 +44,7 @@
4444
"""
4545

4646
# I think this is different from plt12_contours
47-
ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.cm.hot)
47+
ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.get_cmap('rainbow'))
4848
"""
4949
========== ================================================
5050
Argument Description

‎matplotlibTUT/plt15_subplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
Please note, this script is for python3+.
99
If you are using python2+, please modify it accordingly.
10-
Tutorial page:
10+
Tutorial reference:
1111
http://www.scipy-lectures.org/intro/matplotlib/matplotlib.html
1212
"""
1313

‎matplotlibTUT/plt16_grid_subplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
Please note, this script is for python3+.
99
If you are using python2+, please modify it accordingly.
10-
Tutorial page:
10+
Tutorial reference:
1111
http://matplotlib.org/users/gridspec.html
1212
"""
1313

‎matplotlibTUT/plt17_plot_in_plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
Please note, this script is for python3+.
99
If you are using python2+, please modify it accordingly.
10-
Tutorial page:
10+
Tutorial reference:
1111
http://www.python-course.eu/matplotlib_multiple_figures.php
1212
"""
1313

‎matplotlibTUT/plt18_secondary_yaxis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
Please note, this script is for python3+.
99
If you are using python2+, please modify it accordingly.
10-
Tutorial page:
10+
Tutorial reference:
1111
http://www.python-course.eu/matplotlib_multiple_figures.php
1212
"""
1313

‎matplotlibTUT/plt19_animation.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# View more python tutorials on my Youtube and Youku channel!!!
2+
3+
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4+
# Youku video tutorial: http://i.youku.com/pythontutorial
5+
6+
# 19 - animation
7+
"""
8+
Please note, this script is for python3+.
9+
If you are using python2+, please modify it accordingly.
10+
11+
Tutorial reference:
12+
http://matplotlib.org/examples/animation/simple_anim.html
13+
14+
More animation example code:
15+
http://matplotlib.org/examples/animation/
16+
"""
17+
18+
import numpy as np
19+
from matplotlib import pyplot as plt
20+
from matplotlib import animation
21+
22+
fig, ax = plt.subplots()
23+
24+
x = np.arange(0, 2*np.pi, 0.01)
25+
line, = ax.plot(x, np.sin(x))
26+
27+
28+
def animate(i):
29+
line.set_ydata(np.sin(x + i/10.0)) # update the data
30+
return line,
31+
32+
33+
# Init only required for blitting to give a clean slate.
34+
def init():
35+
line.set_ydata(np.ma.array(x, mask=True))
36+
return line,
37+
38+
# call the animator. blit=True means only re-draw the parts that have changed.
39+
# blit=True dose not work on Mac, set blit=False
40+
# interval= update frequency
41+
ani = animation.FuncAnimation(fig=fig, func=animate, frames=100, init_func=init,
42+
interval=20, blit=False)
43+
44+
# save the animation as an mp4. This requires ffmpeg or mencoder to be
45+
# installed. The extra_args ensure that the x264 codec is used, so that
46+
# the video can be embedded in html5. You may need to adjust this for
47+
# your system: for more information, see
48+
# http://matplotlib.sourceforge.net/api/animation_api.html
49+
# anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
50+
51+
plt.show()

0 commit comments

Comments
 (0)