Skip to content

Instantly share code, notes, and snippets.

@cojocar
Created January 7, 2019 11:44
Show Gist options
  • Save cojocar/07d613dde8d18c7fa12397a5db69d29e to your computer and use it in GitHub Desktop.
Save cojocar/07d613dde8d18c7fa12397a5db69d29e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import matplotlib.pyplot as plt
import matplotlib.patches as patches
COLORS = plt.style.library['bmh']['axes.color_cycle']
def show_colors():
fig, ax = plt.subplots(1)
L = 10
H = 40
for idx in range(len(COLORS)):
print(idx)
c = COLORS[idx]
rect = patches.Rectangle((idx*L, 0), L, H, edgecolor=c,facecolor=c)
# Add the patch to the Axes
ax.add_patch(rect)
ax.text(idx*L+L/2, 0, str(idx))
plt.xticks([0, L*len(COLORS)])
plt.show()
show_colors()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment