why does my colorbar have lines in it?

前端 未结 7 542
清歌不尽
清歌不尽 2020-12-03 02:25

Edit: Since this seems to be a popular post, here\'s the solution that seems to be working well for me. Thanks @gazzar and @mfra.

cbar.solid         


        
7条回答
  •  被撕碎了的回忆
    2020-12-03 03:07

    Since none of the other suggestions worked for me I ended up removing the alpha channel from the colorbar instance:

    from matplotlib.colors import to_rgb
    
    lut = colorbar.solids.get_facecolor()
    bg_color = to_rgb('white')
    lut[:, :3] *= lut[:, 3:]
    lut[:, :3] += (1 - lut[:, 3:]) * bg_color
    lut[:, 3] = 1.
    colorbar.solids.set_facecolor(lut)
    

    The colorbar had to be drawn once before being able to access the face colors.

提交回复
热议问题