pyGMT makecpt error: CPT <stdin> has no z-slices!

Hi,

I’d like to invert a (built-in) colour map. I adapted a code from another thread (pyGMT makecpt - background and foreground) to arrive at:
pygmt.makecpt(cmap = "devon", reverse = True, series = [0, 7000, 10], output="devon_r.cpt", continuous = True, M = True)
I have also tried M=" " and running without series=[]

However, when I use this colourmap to plot something, it does plot the colourmap correctly inverted, but no colourbar below the map, and pyGMT returns the error colorbar [ERROR]: CPT <stdin> has no z-slices!.

I have tried the pyGMT manual and tutorials but I have not been able to identify the problem in my code.

Many thanks!!
Thomas

I’m not sure how it works with python, but do you ask for the colorbar to be plotted while specifying the cpt’s name?