Skip to content

Instantly share code, notes, and snippets.

View jonnyhtw's full-sized avatar
💭
eating cheese

Jonny Williams jonnyhtw

💭
eating cheese
  • Wellington, New Zealand
  • 06:48 (UTC -12:00)
View GitHub Profile
@jonnyhtw
jonnyhtw / discrete_cmap.py
Created July 29, 2020 01:52 — forked from jakevdp/discrete_cmap.py
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
import matplotlib.pyplot as plt
import numpy.random as rnd
from matplotlib.patches import Ellipse
NUM = 250
ells = [Ellipse(xy=rnd.rand(2)*10, width=rnd.rand(), height=rnd.rand(), angle=rnd.rand()*360)
for i in range(NUM)]
fig = plt.figure(0)