You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pygmt.Figure.subplot: "frame", "sharex", and "sharey" do not work correctly with "pygmt.Figure.set_panel" #2365
Been trying to set a subtitle using sharex="b+lNormalize" and sharey="l+lAzimuth" but it doesn't show up. Wondering if the +l is broken, or if there's some setting overriding the label...
This issue is also relevant for the frame parameter and affects annotations, ticks and, gridlines.
(1) with fig.set_panel(panel=index): -> Does NOT add x and y labels, and does NOT adjust frame settings Example code:
importpygmtnrows=1ncols=2fig=pygmt.Figure()
withfig.subplot(
nrows=nrows,
ncols=ncols,
figsize=("10c", "5c"),
sharex="b+llabel_x",
sharey="l+llabel_y",
frame="a1f0.5g2",
):
foriinrange(nrows):
forjinrange(ncols):
index=i*nrows+j# does NOT add x and y labels, # does NOT adjust frame settingswithfig.set_panel(panel=index):
fig.basemap(region=[0, 10, 0, 10], projection="X?")
fig.show()
# fig.savefig(fname="issue_frame_doubleloop.png")
Output figure:
(2) panel=True -> Does add x and y axis labels and does adjust frame settings Example code:
importpygmtnrows=1ncols=2fig=pygmt.Figure()
withfig.subplot(
nrows=nrows,
ncols=ncols,
figsize=("10c", "5c"),
sharex="b+llabel_x",
sharey="l+llabel_y",
frame="a1f0.5g2",
):
foriinrange(nrows):
forjinrange(ncols):
# does add x and y labels, # does adjust frame settingsfig.basemap(region=[0, 10, 0, 10], projection="X?", panel=True)
fig.show()
# fig.savefig(fname="issue_frame_panelTrue.png")
changed the title [-]pygmt.Figure.subplot: x and y axis labels set via "sharex" and "sharey" partly not shown[/-][+]pygmt.Figure.subplot: "frame", "sharex", and "sharey" do not work correctly with "pygmt.Figure.set_panel"[/+]on Feb 18, 2023
The problem is related to using pygmt.Figure.basemap directly after pygmt.Figure.set_panel (please see case (1a) vs. case (1b)). For this case, it "works" only if the frame parameter is set again in the same way (please see case (1c)). So, probably the [default] argument passed through the frame parameter of pygmt.Figure.basemap is overwriting the settings via the parameters of pygmt.Figure.subplot.
(1a) pygmt.Figure.set_panel: + using pygmt.Figure.basemap Example code
Activity
yvonnefroehlich commentedon Feb 18, 2023
This issue is also relevant for the
frameparameter and affects annotations, ticks and, gridlines.(1)
with fig.set_panel(panel=index):-> Does NOT add x and y labels, and does NOT adjust frame settingsExample code:
Output figure:

(2)
panel=True-> Does add x and y axis labels and does adjust frame settingsExample code:
Output figure:

[-]pygmt.Figure.subplot: x and y axis labels set via "sharex" and "sharey" partly not shown[/-][+]pygmt.Figure.subplot: "frame", "sharex", and "sharey" do not work correctly with "pygmt.Figure.set_panel"[/+]yvonnefroehlich commentedon Feb 19, 2023
The problem is related to using
pygmt.Figure.basemapdirectly afterpygmt.Figure.set_panel(please see case (1a) vs. case (1b)). For this case, it "works" only if theframeparameter is set again in the same way (please see case (1c)). So, probably the [default] argument passed through theframeparameter ofpygmt.Figure.basemapis overwriting the settings via the parameters ofpygmt.Figure.subplot.(1a)
pygmt.Figure.set_panel:+ usingpygmt.Figure.basemapExample code
Output figure

(1b)
pygmt.Figure.set_panel:+ NOT usingpygmt.Figure.basemapExample code
Output figure

(1c)
pygmt.Figure.set_panel:+ usingpygmt.Figure.basemapWITH setting theframeparameter againExample code
Output figure

seisman commentedon Mar 13, 2023
I think this is the side-effect of the following two lines:
pygmt/pygmt/src/basemap.py
Lines 89 to 90 in 34fed4d
@yvonnefroehlich Could you please try remove these two lines and see if everything works as expected?
yvonnefroehlich commentedon Mar 13, 2023
Thanks for pointing this out @seisman!
Please see PR #2417.
seisman commentedon Mar 27, 2023
Closed by #2417.