Customizing colorbar border color on matplotlib

2019-04-07 01:02发布

how can I change the colorbar borders so that they are white and not black (externals border and between each segment)?

For example:

x=randint(100, size=(10,10))
cs=contourf(x)
cb=colorbar(cs)

give

enter image description here

but I want :

enter image description here

Thanks

2条回答
Root(大扎)
2楼-- · 2019-04-07 01:52

edit: Notice the comments below for MPL 1.3 and later.

Add:

cb=colorbar(cs, drawedges=True)

cb.outline.set_color('white')
cb.outline.set_linewidth(2)

cb.dividers.set_color('white')
cb.dividers.set_linewidth(2)
查看更多
手持菜刀,她持情操
3楼-- · 2019-04-07 01:59

As PiQuer mentioned:

cb.outline.set_edgecolor('white')

works nowadays

查看更多
登录 后发表回答