Here is the explanation of the preceding code:
- matplotlib.use('tkAgg') sets the backend to Tkinter.
- x, y, z = iris['petal_length'], iris['petal_width'], iris['species'] prepares the data for the x, y, and z coordinates. We are plotting petal_length and petal_width on the x and y axes, then species (cluster number) on the z axis.
- ax.scatter(x[index], y[index], z[index], s=25*x[index]*y[index], c=c, marker=marker) is similar to a 2D scatter plot syntax, except that we also include the z axis.
- To create an animation, we use a for loop and keep changing the view rotation angle from 0 to 360 degrees:
- ax.view_init(30, angle) keeps the elevation angle fixed at 30 degrees and varies the rotation angle by one degree in each iteration ...