如何使用颜色图从pyplot.Jl作为julia-lang中的函数



如何进入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中

?一般来说,我正在寻找一种方法,从使用Pyplot的颜色图中获得RGB列表。

使用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)

最新更新