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: https://sis-dev.climate.copernicus.eu/toolbox-editor/1474/uc1-humidity-and-its-variability-over-latitude-and-height


Thank you,

Huayuan.


2 Comments

  1. 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.

    Regards.

    Vivien

    1. 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