Hey everyone,
I am new to PyGMT and I am trying to create subplots in PyGMT. I’ve set the colorbar position to be in the bottom center, however, it doesn’t run like that.
I have the following code so far:
import pygmt
path = r'E:\day'
fig = pygmt.Figure()
lowest = 255
highest = 325
interval = (highest - lowest) / 64
pygmt.makecpt(cmap="jet", series=[lowest, highest, interval])
with pygmt.config(FONT_TITLE="18p,5", MAP_TITLE_OFFSET="-12p", MAP_FRAME_TYPE="plain"):
with fig.subplot(
nrows=4,
ncols=6,
figsize=("42c", "28c"),
margins=["0.2c", "0.2c"],
):
for i in range(0, 24):
fig.grdimage(
grid=fr'{path}\2013276_{str(i).zfill(2)}.tif',
frame=[f"lbtr+t{str(i).zfill(2)}:00"],
cmap=True,
panel=True,
#dpi=300,
)
with pygmt.config(FONT="18p,4"):
fig.colorbar(position="JBC+w10c/0.5c+h", frame=["a10f10", "y+lLST (K)"])
fig.show()
One more question, how to set the colorbar annotation to show only the minimum and maximum values? The final result I would like to get is shown below.
Hello @yvonnefroehlich Thank you so much for your help. I have one more question. How to set the colorbar annotation to show only the minimum and maximum values? The final result I would like to get is shown below.
Your code is incomplete and not working, and thus it is not possible to reproduce your issue.
Please provide a code example that directly demonstrates your issue.
Thank you very much for your help and suggestions. I created a new Jupyter Notebook file to test the issue, and strangely, the results showed the colorbar position as normal. However, the complete example requires a large amount of data, which makes it difficult to reproduce the issue directly.
That said, I have encountered similar problems before: sometimes no manual adjustment is needed, while other times it is required. I work on both a Mac and multiple different Ubuntu systems, and I’m not sure if this might have some impact. I am actively working on finding a simpler example to reproduce this error. As soon as I identify one, I will let you know immediately.
I sincerely apologize for any inconvenience caused and appreciate your understanding.