Reproducing line colors with a custom CPT tutorial


I’ve tried to reproduce this tutorial and noticed that the output of this looks like this:

rather than

as indicated on the tutorial’s website. (Note the labeling of the colorbar for both plots)

How can I get the colorbar labeling of the second figure (integers rather than ranges)?

The source code was just copied from the website, and looks like this:

import numpy as np
import pygmt

# Create a list of values between 20 and 30 with 0.2 intervals
x = np.arange(start=20, stop=30, step=0.2)

fig = pygmt.Figure()
fig.basemap(frame=["WSne", "af"], region=[20, 30, -10, 10])

# Create a custom CPT with the batlow CPT and 10 discrete z-values (colors),
# use color_model="+c0-9" to write the color palette in categorical format and
# add labels (0) to (9) for the colorbar legend
pygmt.makecpt(cmap="batlow", series=[0, 9, 1], color_model="+c0-9")

# Plot 10 lines and set a different z-value for each line
for zvalue in range(0, 10):
y = zvalue * np.sin(x)
fig.plot(x=x, y=y, cmap=True, zvalue=zvalue, pen="thick,+z,-")

# Color bar to show the custom CPT and the associated z-values