透明色图

Enn*_*ppa 5 python numpy matplotlib color-mapping

我想得到像这个密度的密度分布图http://www.nicolacarlon.it/out.png 与alpha通道而不是像这个密度的蓝色通道http://www.nicolacarlon.it/out2.png

我发现这个代码,但它不起作用:(

    theCM = cm.get_cmap()
    theCM._init()
    alphas = np.abs(np.linspace(-1.0, 1.0, theCM.N))
    theCM._lut[:-3,-1] = alphas
    plt.imshow(img, cmap=theCM)
    plt.savefig("out.svg", transparent=True)
Run Code Online (Sandbox Code Playgroud)