A (stupid) workaround for clabel not respecting zorder of parent contour object

My contour labels sometimes appear below my contourf or pcolormesh objects, even when my contour objects appear (correctly) on top. I know clabel does not accept zorder as a kwarg, so what’s the workaround for this bug?

It turns out it’s as easy as making sure you plot the contour before the contourf or pcolormesh.

Image 1, contour before pcolormesh. Notice the contour label on top of the blue and green color (radar echoes of snow, in this case) in central Michigan.

Image 2, pcolormesh before contour. Notice the contours are still overlaid on the pcolormesh as desired, but there is now a break and empty space where the label should be in central Michigan because the label is underneath the pcolormesh.

(The images are actually one hour apart in time but they represent my issue well.)

It would be much more elegant to have clabel either respect the zorder of its parent contour object, or take zorder as a kwarg of its own, than to have to play this game. Not only is this unelegant, it’s also illogical. If all else was equal, you would expect the last/most recent object would overlay on top of the earlier ones. But as you can see below, that is not the case.


Matplotlib v3.0.2 on Anaconda on Win10

1 Like

That actually sounds like a bug/feature that should be added to clabel? I can’t think of any good reason that clabel can take a zorder, and it should default to the same zorder as the contours. Care to submit an issue?