from colormap import rgb2hex import numpy as np from matplotlib import pyplot as plt color_names = [] sample = [0, 0.25, 0.5, 0.75, 1] # 可以根據自己情況進行設置 for i in sample: for j in sample: for k in sample: col = rgb2hex(i, j, k, normalised=True) color_names.append(col) # print(color_names[0]) x = np.random.random((1000, 1)) j = 0 for i in range(len(color_names)): y = j*3 + np.random.random((1000, 1)) * 2 j += 1 plt.plot(x, y, 'o', color=color_names[i]) plt.show()
生成類似於‘#000000’這樣的colorname,可以應用到plot或者scatter的畫圖函數中,作為color的參數
顏色結果圖如下:
不同的name名字表示不同的顏色