# I found a blog that writes cool 3D in Python

http://geoffboeing.com/2015/04/animated-3d-plots-python/

This blog is cool, so buy the Japanese version, make it, and share it!

The bottom line is that this blog alone won't work with Python 3.
In the first place, images2gif is python2.

So, as soon as you google "images2gif python3", you will reach the following Github

https://github.com/isaacgerg/images2gif

For the time being, do this locally, `python images2gif.py`

and hopefully. The following Gif can be created.

And integrate with the one on the blog above!

If you have already installed images2gif with python3, delete it with `pip uninstall images2gif`

or something.

Then import images2gif.py brought directly from Github above.

## Import what you need (use as it is from the blog)

```
import pandas as pd, numpy as np, random
import matplotlib.pyplot as plt, matplotlib.cm as cm
from mpl_toolkits.mplot3d import Axes3D
import IPython.display as IPdisplay
import glob
from PIL import Image as PIL_Image
from images2gif import writeGif
```

## Write 3d images in Axes 3D (I wrote it myself)

```
gif_file_name = '3d_test'
x = np.arange(-3, 3, 0.25)
y = np.arange(-3, 3, 0.25)
x = np.arange(-3, 3, 0.25)
y = np.arange(-3, 3, 0.25)
X, Y = np.meshgrid(x, y)
Z = np.sin(X)+ np.cos(Y)
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_wireframe(X, Y, Z)
```

## Save 100 images with different angles (use blog as it is)

```
ax.elev = 89.9
ax.azim = 270.1
ax.dist = 11.0
for n in range(100):
if n >= 20 and n <= 22:
ax.set_xlabel('')
ax.set_ylabel('') #don't show axis labels while we move around, it looks weird
ax.elev -= 0.5 #start by panning down slowly
if n >= 23 and n <= 36:
ax.elev -= 1.0 #pan down faster
if n >= 37 and n <= 60:
ax.elev -= 1.5
ax.azim += 1.1 #pan down faster and start to rotate
if n >= 61 and n <= 64:
ax.elev -= 1.0
ax.azim += 1.1 #pan down slower and rotate same speed
if n >= 65 and n <= 73:
ax.elev -= 0.5
ax.azim += 1.1 #pan down slowly and rotate same speed
if n >= 74 and n <= 76:
ax.elev -= 0.2
ax.azim += 0.5 #end by panning/rotating slowly to stopping position
if n == 77:
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
fig.suptitle('Practice')
fig.savefig('images/' + 'img' + str(n).zfill(3) + '.png')
```

## Finally create a gif from 100 images

```
images = [PIL_Image.open(image) for image in glob.glob('images/*.png')]
file_path_name = 'images/3d_test.gif'
writeGif(file_path_name, images, duration=0.1)
```

Now you have the following! (The image is compressed and the gif does not work w ...)

There is no way, so create a 5-frame version ↓