Colorbar round edges

Hello everyone,

Is there a way to create a colorbar with the top and bottom edges being rounded, like in the image below?


Thank you!

Anything is possible, but not automatically.

What strategy would you suggest to tackle this?

I can hide the edges and since colorbar is an axis i can draw my custom curved lines, but the first and last colors are squares so they will intersect with the curves.
Probably the place to start is the implementation of the extended colorbar with the triangle top and bottom edges. I ll have a look.

I wouldn’t implement this until Enh better colorbar axes by jklymak · Pull Request #18900 · matplotlib/matplotlib · GitHub goes in. It is changing the end regions from a distorted pcolormesh to a triangle patch. If its a triangle patch, its pretty easy to make a rounded patch.

1 Like