Here is the explanation of the preceding code blocks:
- ax = fig.add_axes([0, 0, 1, 1], frameon=False) sets the axes,and frameon=False specifies not to plot the spines.
- n_bubbles = 50 sets the number of bubbles to 50.
- bubbles defines the data structure with position, size, growth factor, and color and initializes all of them with zeros. The position is the x and y coordinates, size and growth are one attribute each, and color is RGBA, hence four attributes.
- bubbles['position'] = np.random.uniform(0, 1, (n_bubbles, 2)) sets the initial position for all bubbles randomly with all coordinates between zero and 1.
- ax.scatter() plots the scatter plot with position coordinates, size, and color arguments.
- def animate(frame_number): ...