好吧,我不知道有什么直接的方法可以得到完全相同的结果,但是由于没有其他的响应,让我指出如果您来自r,python通常是如何实现的。
选择颜色范围的一种方法是选择matplotlib包的预先制作的颜色图。您可以在此处查看大多数可用的彩色地图:
https://matplotlib.org/users/colormaps.html
.
另一个很好的函数是彩虹函数,它可以根据您需要的颜色创建颜色光谱:
import matplotlib.cm as cm
NrCol = #Enter formula or methode to calculate total number of colours needed
colour = cm.rainbow(np.linspace(0,1,NrCol))
for j in range(NrCol):
color = colour[j] #this is the specific colour that you would never stand alone like this but rather use in a plot function
在你得到的所有颜色中,你当然可以选择一个特定的范围,但这将是一个非常粗糙的,硬编码的解决方案。