与Julia-lang相似的方法是什么?
import numpy as np
import matplotlib.pyplot as plt
i = 0, f = 255, N = 100
colors = [ plt.cm.viridis(x) for x in np.linspace(i, f, N) ]
在Python中?一般来说,我正在寻找一种方法,使用Julia-lang中的Pyplot.jl以及所需数量的颜色(N)从色彩图中获取RGB列表。
答案 0 :(得分:3)
这是最简单的使用PlotUtils(在using Plots
上重新导出):
julia> using PlotUtils
julia> cm = cgrad(:viridis);
julia> colors = [cm[i] for i in linspace(0,1,10)]
10-element Array{ColorTypes.RGBA{Float64},1}:
RGBA{Float64}(0.267004,0.004874,0.329415,1.0)
RGBA{Float64}(0.280935,0.155726,0.468508,1.0)
RGBA{Float64}(0.242949,0.291862,0.537908,1.0)
RGBA{Float64}(0.190784,0.406937,0.555933,1.0)
RGBA{Float64}(0.147463,0.512137,0.556955,1.0)
RGBA{Float64}(0.120243,0.618071,0.536316,1.0)
RGBA{Float64}(0.209417,0.718547,0.472197,1.0)
RGBA{Float64}(0.422721,0.805438,0.351155,1.0)
RGBA{Float64}(0.710003,0.8685,0.169494,1.0)
RGBA{Float64}(0.993248,0.906157,0.143936,1.0)