【问题标题】:Transparent colormap透明色图
【发布时间】:2011-12-20 19:07:54
【问题描述】:

我想得到这样的密度分布图density http://www.nicolacarlon.it/out.png 使用 alpha 通道而不是像这样的蓝色通道 density 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)

【问题讨论】:

  • 'out.svg' 产生什么?它有什么问题?
  • 制作第一张图片。
  • 如果我写 theCM=cm.get_cmap('hvs') 我会得到一个具有正常 hvs 颜色图的图像:(
  • 0.99.3-1ubuntu1(使用 apt-get python-matplotlib)
  • 如果我注释代码的第 3 行和第 4 行,我会得到相同的结果...

标签: python numpy matplotlib color-mapping


【解决方案1】:

这是 matplotlib 的 Colormap 类的一个错误。它存在于 matplotlib 的 0.99.x 版本中,但从 1.x 开始已修复。请参阅bug fix 了解如何修复它。升级到最新版本应该可以解决这个问题。无法解决此错误,因此升级是唯一的选择。

【讨论】:

    猜你喜欢
    • 2020-11-29
    • 2017-06-04
    • 1970-01-01
    • 2017-11-20
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-09
    相关资源
    最近更新 更多