如果我通过例如:import numpy as np从matplotlib import pyplot创建颜色为plt
n = 6
color = plt.cm.coolwarm(np.linspace(0.1,0.9,n))
color
Run Code Online (Sandbox Code Playgroud)
颜色是一个numpy数组:
array([[ 0.34832334, 0.46571115, 0.88834616, 1. ],
[ 0.56518158, 0.69943844, 0.99663507, 1. ],
[ 0.77737753, 0.84092121, 0.9461493 , 1. ],
[ 0.93577377, 0.8122367 , 0.74715647, 1. ],
[ 0.96049006, 0.61627642, 0.4954666 , 1. ],
[ 0.83936494, 0.32185622, 0.26492398, 1. ]])
但是,如果我在我的.mplstyle
文件(map(tuple,color[:,0:-1])
)中插入RGB值(没有alpha值1)作为元组,我会得到类似于这个的错误:
in file "/home/moritz/.config/matplotlib/stylelib/ggplot.mplstyle"
Key axes.color_cycle: [(0.34832334141176474 does not look like a color arg
(val, error_details, msg))
任何想法为什么?