Convert y-tick labels from m to km in Pcolormesh plot

Hello, I want to convert the y-axis tick labels from m to km in my Pcolormesh plot (see above). I am not sure how this can be done.

Is there a kwarg in Pcolormesh settings where one can type in the y-tick labels manually? or is there some way you can divide the y with 1000?

Code used to plot:

fig = fig,
levels = lvls, colors=clr,

link to full application:

Thank you,


Dear Huayuan,

Somehow I was not able to run your workflow but the using keyword y_convert_units='km' should help doing what you are trying to achieve.

I have not been able to test it so please let me know if it worked.



I just got the application running again. Unfortunately, the fix does not work. I receive the following error:

raise ValueError("Can't convert %r to %r." % (source_units, target_units))
ValueError: Can't convert 'g/kg' to 'km'.

Somehow, it is trying to convert the z heatmap values instead of the y-axis