Skip to content

Figure.set_panel: Fix the bug when panel is not set#4628

Open
seisman wants to merge 1 commit intomainfrom
codex/fix-set-panel-default
Open

Figure.set_panel: Fix the bug when panel is not set#4628
seisman wants to merge 1 commit intomainfrom
codex/fix-set-panel-default

Conversation

@seisman
Copy link
Copy Markdown
Member

@seisman seisman commented May 8, 2026

In the GMT CLI, using gmt subplot set without specifying the panel activates the next panel. For example:

gmt begin map
	gmt subplot begin 1x2 -Fs6c/3c
	gmt subplot set
	gmt basemap -R0/3/0/3 -B
	gmt subplot set 
	gmt basemap -R0/3/0/3 -B
	gmt subplot end
gmt end show

The equivalent PyGMT script is:

import pygmt

fig = pygmt.Figure()
with fig.subplot(nrows=1, ncols=2, figsize=("6c", "3c")):
     with fig.set_panel():
         fig.basemap(region=[0, 3, 0, 3], frame=True)
     with fig.set_panel():
         fig.basemap(region=[0, 3, 0, 3], frame=True)
fig.show()

But it doesn't work as expected:

subplot [ERROR]: No subplot information file!
...

The bug is because we always pass panel to gmt subplot set even if it's None. The bug can be traced back to the initial implementation in PR #822.

This PR fixes the long-term bug and add a test for it.

@seisman seisman added this to the 0.19.0 milestone May 8, 2026
@seisman seisman added bug Something isn't working needs review This PR has higher priority and needs review. labels May 8, 2026
@seisman seisman force-pushed the codex/fix-set-panel-default branch from bcd0848 to 787c461 Compare May 8, 2026 06:39
@seisman seisman force-pushed the codex/fix-set-panel-default branch from 787c461 to 380753f Compare May 8, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant