Skip to content

Fix reverse cmap issues - #20

Merged
lispandfound merged 1 commit into
mainfrom
reverse_cmap
Jul 16, 2026
Merged

Fix reverse cmap issues#20
lispandfound merged 1 commit into
mainfrom
reverse_cmap

Conversation

@lispandfound

@lispandfound lispandfound commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Fixes an issue with the plot grid functionality when reverse cmap is disabled: the limit colours are incorrectly assigned. Fixes #19

@lispandfound
lispandfound requested a review from Copilot July 16, 2026 22:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the plot_grid function in pygmt_helper/plotting.py to swap the background and foreground limit colors when reverse_cmap is enabled. The review feedback suggests simplifying this conditional assignment to make it more idiomatic and concise using tuple slicing.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pygmt_helper/plotting.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes how out-of-range colormap “limit colors” are assigned in plot_grid when reverse_cmap=False, addressing Issue #19 where the background/foreground colors were effectively reversed in the non-reversed colormap case.

Changes:

  • Add conditional logic so COLOR_BACKGROUND/COLOR_FOREGROUND are assigned based on reverse_cmap, instead of always using the same order.
  • Document (inline) why the swap is needed when reverse_cmap is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pygmt_helper/plotting.py
Comment on lines 488 to +495
# Set the background & foreground colour for the colormap
pygmt.config(
COLOR_BACKGROUND=cmap_limit_colors[1], COLOR_FOREGROUND=cmap_limit_colors[0]
)
# When reverse_cmap is True, the cmap is reversed so the limit colours
# must be swapped to stay correct for values below/above the range.
if reverse_cmap:
bg_color, fg_color = cmap_limit_colors[1], cmap_limit_colors[0]
else:
bg_color, fg_color = cmap_limit_colors[0], cmap_limit_colors[1]
pygmt.config(COLOR_BACKGROUND=bg_color, COLOR_FOREGROUND=fg_color)
@lispandfound
lispandfound merged commit e83ea17 into main Jul 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect cmap limits set

2 participants