I had a hard time installing ImageMagick and PythonMagick, the libraries needed to make animated GIFs in Python, so I'll note how to do it here.
Like this Like this You can generate something like this.
sudo dscl . -append /Groups/wheel GroupMembership <user name>
sudo chmod -R g+w /usr/local/include/
sudo chmod -R g+w /usr/local/share/man/man5
sudo chmod -R g+w /usr/local/lib/
brew link libpng
brew install imagemagick
brew install boost
brew install boost-python
sudo chmod -R g+w /usr/local/share/info
brew link libtool
Download Python Magick http://www.imagemagick.org/download/python/
cd /path/to/PythonMagick-0.9.12
./configure
make
I get an error. .. ..
error
CXXLD _PythonMagick.la
clang: warning: argument unused during compilation: '-pthread'
ld: warning: directory not found for option '-L/usr/local/Cellar/freetype/2.6/lib'
When I looked it up, in my environment
/usr/local/Cellar/freetype/2.6_1/lib/
Seems to be the correct path.
Find the file to modify.
find ./ -type f -print | xargs grep 'freetype' -n
Since it was directly under / path / to / PythonMagick-0.9.12
,
vi _PythonMagick.la
So, I corrected the path. take heart,
make
sudo make install
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation as ani
plt.style.use('ggplot')
num_frame = 80.
x_range= 7
def animate(nframe):
global num_frame
plt.clf()
a = ((5*nframe/num_frame) -.5) * np.pi
x = np.linspace(-x_range, x_range, 200)
y = np.sin(x+a)
plt.xlim(-x_range, x_range)
plt.ylim(-1.1,1.1)
plt.plot(x, y, c="b")
fig = plt.figure(figsize=(12,5))
anim = ani.FuncAnimation(fig, animate, frames=int(num_frame))
anim.save('anim_test.gif', writer='imagemagick', fps=5, dpi=64)
It's done!
Recommended Posts