Setting frame border color on matplotlib

how can I change the borders of the color bar so that they are white and not black (the outer border and between each segment)?

For instance:

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

give

enter image description here

but I want:

enter image description here

thank

+5
source share
2 answers

edit: Pay attention to 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)
+11
source

As PiQuer mentioned:

cb.outline.set_edgecolor('white')

works now

0
source

All Articles