Matplotlib cycle plot colors endlessly

To allow a for loop to make an arbitrary number of overlaid plots in a single axes, we may wish to endlessly cycle colors using itertools. This technique only makes sense up to a few dozen cycles depending on the Matplotlib color palette but it can be better than just ending a loop after the palette is exhausted.

import itertools

import matplotlib.pyplot as plt
import matplotlib.colors as mplcolors

color_cycle = itertools.cycle(mplcolors.TABLEAU_COLORS)

xy = [(x, x**1.2) for x in range(20)]
# toy data

ax = plt.figure().gca()

for (x, y), color in zip(xy, color_cycle):
    ax.scatter(x, y, color=color)

print(xy)

plt.show()