If anyone is interested in how to create the polar plots from the generated gray codes, here is some code for completeness (thanks OP for an interesting exercise on numpy
and gray codes). Set an oversampling
for small bit counts to make the plot smooth.
def plot_gray_codes(gc, oversampling=1):
import matplotlib.pyplot as plt
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
# Set an oversampling factor to make the polar plot smoother for small bit counts
gc = np.repeat(gc, oversampling, axis=0) if oversampling > 1 else gc
for i, j in zip(*np.where(gc)):
ax.fill_between([i * 2 * np.pi / gc.shape[0], (i + 1) * 2 * np.pi / gc.shape[0]], [j, j], [j+1, j+1], color='black')
ax.set_aspect('equal')
plt.axis('off')
plt.tight_layout()
plt.show()