COLOR VALUES IN MATPLOTLIB
Listing 5.3 displays the content of mat_colors.py that shows the colors that are available in Matplotlib.
LISTING 5.3: heatmap1.py
import matplotlib
import matplotlib.pyplot as plt
colors = plt.colormaps()
col_count=5
idx=0
for color in colors:
if(color.endswith("_r") == False):
print(color," ",end="")
idx += 1
if(idx % col_count == 0):
print()
print()
print("=> color count:",idx)
Listing 5.3 contains two import statements, after which the variable colors are initialized with the list of available colors. The next portion of Listing 5.3 contains a loop that iterates through the colors variable, and prints the value of each color, provided that it does not have the suffix “_r” in its name. A new line is printed each time that five colors have been printed. Launch the code in Listing 5.3, and you will see the following output:
Accent Blues BrBG BuGn BuPu CMRmap Dark2 GnBu Greens...