Skip to content

Instantly share code, notes, and snippets.

@snsinfu
Created April 8, 2021 09:13
Show Gist options
  • Select an option

  • Save snsinfu/b79a5ca823a1b3e5f134d4a883561e76 to your computer and use it in GitHub Desktop.

Select an option

Save snsinfu/b79a5ca823a1b3e5f134d4a883561e76 to your computer and use it in GitHub Desktop.
[matplotlib] Add named colors (from prop cycle)
plt.style.use("paper")
# Name prop colors. You may need to change it to match your matplotlib style to use.
names = ["nb:blue", "nb:red", "nb:green", "nb:yellow", "nb:cyan", "nb:purple", "nb:magenta", "nb:gray"]
props = plt.rcParams["axes.prop_cycle"]
assert len(names) == len(props)
cc = plt.cm.colors.colorConverter
for name, prop in zip(names, props):
cc.colors[name] = prop["color"]
cc.cache = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment