Problem
pygmt.makecpt
works the first time, but on subsequent attempts, it is ignored and the first-generated CPT is used.
I have found I can use makecpt multiple times by reloading pygmt,
but I do not think it is natural way.
Question
- In the example below why is the second
makecpt
ignored? - Are there any other ways to use makecpt multiple times?
Example
- run on jupyter
- pygmt version: 0.14.0
import importlib
import pygmt
rgn = [90, 180, 0, 60]
prj = "M5c"
grd = pygmt.datasets.load_earth_relief(
resolution="15m",
region = rgn,
)
importlib.reload(pygmt)
with pygmt.config(
MAP_TITLE_OFFSET = "-5p",
FONT_LABEL = "1p",
FONT_TITLE = "10p",
):
# =======================
# fig. 1
# =======================
pygmt.makecpt(
cmap="relief",
series = [-8000,8000],
)
fig = pygmt.Figure()
fig.grdimage(
grid = grd,
projection = prj,
region = rgn,
frame = [
"af",
"+tFig. 1",
],
)
fig.show()
# =======================
# fig. 2
# =======================
# reload
# importlib.reload(pygmt)
pygmt.makecpt(
cmap="geo",
series = [-8000,8000],
)
fig = pygmt.Figure()
fig.grdimage(
grid = grd,
projection = prj,
region = rgn,
frame = [
"af",
"+tFig. 2",
],
)
fig.show()
Output
I tried to generate two colormaps from relief
and geo
,
but the same cmap derives from relief
is used for both fig. 1 and fig. 2.
If I reload pygmt before the second makecpt
, it works correctly.
In this case, I know I can change cmap by giving cmap
in grdimage
.
Here, the problem is I can not make multiple cmaps in one session without reloading pygmt.