Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing colorbar border color on matplotlib

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

like image 860
LionelR Avatar asked Jan 23 '13 10:01

LionelR


2 Answers

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)
like image 92
Rutger Kassies Avatar answered Sep 16 '22 17:09

Rutger Kassies


As PiQuer mentioned:

cb.outline.set_edgecolor('white')

works nowadays

like image 45
Markus Dutschke Avatar answered Sep 20 '22 17:09

Markus Dutschke