Skip to content

Commit

Permalink
fix: adding random colour generator
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Oct 9, 2024
1 parent 464934b commit 1a850c2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions LoopStructural/utils/colours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from LoopStructural.utils import rng


def random_colour(n: int, cmap='tab20'):
"""
Generate a list of random colours
Parameters
----------
n : int
Number of colours to generate
cmap : str, optional
Name of the matplotlib colour map to use, by default 'tab20'
Returns
-------
list
List of colours in the form of (r,g,b,a) tuples
"""
import matplotlib.cm as cm

colours = []
for _i in range(n):
colours.append(cm.get_cmap(cmap)(rng.random()))

return colours

0 comments on commit 1a850c2

Please sign in to comment.