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

**URL:** <https://forum.ecmwf.int/t/convert-y-tick-labels-from-m-to-km-in-pcolormesh-plot/1782>\
**Category:** Other - Software and tools\
**Tags:** c3s, toolbox\
**Created:** [1 October 2020 19:13 UTC](https://forum.ecmwf.int/t/convert-y-tick-labels-from-m-to-km-in-pcolormesh-plot/1782 "2020-10-01T19:13:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huayuan\_Song](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/c77e96/32.png) [@Huayuan\_Song](https://forum.ecmwf.int/u/Huayuan_Song)\
**Post date:** [1 October 2020 19:13 UTC](https://forum.ecmwf.int/t/convert-y-tick-labels-from-m-to-km-in-pcolormesh-plot/1782/1 "2020-10-01T19:13:13Z")

</div>

![](https://forum.ecmwf.int/uploads/default/original/1X/8474853f79f03b78b422ef91949368e931b2da30.png)

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:

ct.cdsplot.pcolormesh(data\_con,   
 fig = fig,   
 levels = lvls, colors=clr,  
 x='lat',   
 y='height',  
 ylim=[0,1.2e4],  
 cbar\_kwargs={'orientation':'horizontal','shrink':0.78,'label':'[g/kg]'})

link to full application:&nbsp;[https://sis-dev.climate.copernicus.eu/toolbox-editor/1474/uc1-humidity-and-its-variability-over-latitude-and-height](https://sis-dev.climate.copernicus.eu/toolbox-editor/1474/uc1-humidity-and-its-variability-over-latitude-and-height)

Thank you,

Huayuan.

---

<div class="post-metadata">

**Author:** ![Vivien\_MAVEL](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/v/ecccb3/32.png) [@Vivien\_MAVEL](https://forum.ecmwf.int/u/Vivien_MAVEL)\
**Post date:** [5 October 2020 15:28 UTC](https://forum.ecmwf.int/t/convert-y-tick-labels-from-m-to-km-in-pcolormesh-plot/1782/2 "2020-10-05T15:28:29Z")

</div>

Dear Huayuan,

Somehow I was not able to run your workflow but the using keyword&nbsp;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.

Regards.

Vivien

---

<div class="post-metadata">

**Author:** ![Huayuan\_Song](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/h/c77e96/32.png) [@Huayuan\_Song](https://forum.ecmwf.int/u/Huayuan_Song)\
**Post date:** [8 October 2020 15:13 UTC](https://forum.ecmwf.int/t/convert-y-tick-labels-from-m-to-km-in-pcolormesh-plot/1782/3 "2020-10-08T15:13:46Z")

</div>

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
```
