Hi,
import pygmt
fig1 = pygmt.Figure()
pygmt.config(
FONT_TITLE="10p"
)
with fig1.subplot(
nrows=2,
ncols=1,
figsize=("12c", "7c"),
clearance="1c",
):
fig1.basemap(region=[0, 6, 0, 5], panel=[0, 0],frame="+t a) Apple")
fig1.basemap(region=[0, 6, 0, 5], panel=[1, 0],frame="+t a) Apple")
fig1.show()
How can I bring the title to the top left?
Thank you.
The problem does not make sense the way you present it.
If plot title title is the same, there is no point repeating the title, as only panel label a)
matters . If titles are different, there is no point putting a)
and b
in the title or panel labels.
like in pygmt tutorial: Making subplots — PyGMT
otherwise moving title is not possible as far as I know. However, you can plot a text string manually like here at top center and add offsets: Plotting text — PyGMT
Thank you for your response. The code above was an example.
Yes, the titles are different and I am not quite sure this
Autolabel
seems an alternate way but I prefer to use title for each subplots.
So, I was looking if I can adjust the title to the top left.
you cannot adjust title placement, but you can place a text string manually instead
fig1.text(position="TL", text="a) Apple", justify= "BL", offset="0.1c/0.1c", no_clip=True, font='8p,Helvetica,red')
1 Like
Hello @Idontknow_007,
maybe the parameter fixedlabel
of Figure.set_panel
can help you here. The position of the label can be adjusted via the autolabel
parameter of Figure.subplot
.
import pygmt
fig1 = pygmt.Figure()
pygmt.config(FONT="10p")
with fig1.subplot(
nrows=2,
ncols=1,
figsize=["12c", "7c"],
clearance="1c",
frame=["WStr", "af"],
autolabel="+jTL+o0.6c/0.5c" # Adjust position of label
):
with fig1.set_panel(0, fixedlabel="a) Apple"): # Use a custom label
fig1.basemap(region=[0, 6, 0, 5], projection="X?")
with fig1.set_panel(1, fixedlabel="b) Banana"):
fig1.basemap(region=[0, 6, 0, 5], projection="X?")
fig1.show()
Gives this figure:
1 Like