Skip to content

Instantly share code, notes, and snippets.

@barrysmyth
Last active May 26, 2020 08:46
Show Gist options
  • Save barrysmyth/f2e3b765302868dd4048f1b985706c07 to your computer and use it in GitHub Desktop.
Save barrysmyth/f2e3b765302868dd4048f1b985706c07 to your computer and use it in GitHub Desktop.
# Use the coolwarm colour map, which comes with Matplotlib.
cmap = plt.cm.coolwarm
# Normalise the log-deaths into a 0, 1 scale
norm = colors.Normalize(vmin=deaths.min(), vmax=deaths.max())
# Now the ith colour in colours corresponds to the ith country in deaths.
colours = cmap(norm(deaths))
# Build a simple colour dictionary indexed by country name.
colour_dict = dict(zip(deaths.index, colours))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment