juancopi81 commited on
Commit
520354b
1 Parent(s): 80f9ee2

Add CSS4 list of color to avoid index out of rande

Browse files
Files changed (1) hide show
  1. utils.py +3 -1
utils.py CHANGED
@@ -1,5 +1,6 @@
1
 
2
  import collections
 
3
 
4
  import pandas as pd
5
  import matplotlib.pyplot as plt
@@ -30,7 +31,8 @@ def dataframe_to_pianoroll_img(df):
30
  fig = plt.figure(figsize=(8, 5))
31
  ax = fig.add_subplot(111)
32
  ax.scatter(df.start_time, df.pitch, c="white")
33
- colors = [mcolors.TABLEAU_COLORS[name] for i, name in enumerate(list(mcolors.TABLEAU_COLORS))]
 
34
  colordict = {inst: colors[i] for i, inst in enumerate(df["instrument"].unique())}
35
  for _, row in df.iterrows():
36
  ax.add_patch(Rectangle((row["start_time"],
 
1
 
2
  import collections
3
+ import random
4
 
5
  import pandas as pd
6
  import matplotlib.pyplot as plt
 
31
  fig = plt.figure(figsize=(8, 5))
32
  ax = fig.add_subplot(111)
33
  ax.scatter(df.start_time, df.pitch, c="white")
34
+ colors = [mcolors.CSS4_COLORS[name] for i, name in enumerate(list(mcolors.CSS4_COLORS))]
35
+ random.shuffle(colors)
36
  colordict = {inst: colors[i] for i, inst in enumerate(df["instrument"].unique())}
37
  for _, row in df.iterrows():
38
  ax.add_patch(Rectangle((row["start_time"],