Skip to content

Figure.colorbar: Add alias "no_font_scaling" for "H" - #4783

Merged
seisman merged 20 commits into
mainfrom
add-alias-H-colorbar
Nov 23, 2026
Merged

seisman merged 20 commits into
mainfrom
add-alias-H-colorbar

Conversation

@yvonnefroehlich

@yvonnefroehlich yvonnefroehlich commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Description of proposed changes

This PR aims to add an alias for the newly added -H flag of colorbar of GMT 6.7.0. Currently it's no_font_scaling. Feel free to make suggestion for a suitable alias.

TODO

  • Find alias name: no_font_scaling default False
  • Add alias
  • Update note
  • Be more accurate with length and width of the colorbar
  • check for GMT version >=6.7.0

Related: #4243

Preview: https://pygmt-dev--4783.org.readthedocs.build/en/4783/api/generated/pygmt.Figure.colorbar.html

Example

import pygmt

size = 5
args_bmap = {
    "region": [-size, size] * 2,
    "projection": f"X{size * 2}c",
    "frame": True,
}
args_cb = {
    "cmap": "batlow",
    "position": "jMC+h+w1c",
    "frame": "x+ltitle for a very short cb",
}


fig = pygmt.Figure()

fig.basemap(**args_bmap)
fig.colorbar(**args_cb)

fig.shift_origin(xshift=f"+{size*2+1}c")

fig.basemap(**args_bmap)
fig.colorbar(no_font_scaling=True, **args_cb)   # H = True

fig.show()

Guidelines

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@yvonnefroehlich yvonnefroehlich added this to the 0.20.0 milestone Jul 30, 2026
@yvonnefroehlich yvonnefroehlich self-assigned this Jul 30, 2026
@yvonnefroehlich yvonnefroehlich added enhancement Improving an existing feature feature Brand new feature labels Jul 30, 2026
@seisman

seisman commented Jul 30, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default
to True

@yvonnefroehlich

Copy link
Copy Markdown
Member Author

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are:
In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

@seisman

seisman commented Jul 31, 2026

Copy link
Copy Markdown
Member

we can use not font_scaling internally

@seisman

seisman commented Aug 10, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are: In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

After thinking it twice, I agree that font_scaling=True as the default is confusing. So let's use no_font_scaling.

Comment thread pygmt/src/colorbar.py Resolved
Comment thread pygmt/src/colorbar.py
turn of the this automatic fontsize scaling.
$projection
$region
$verbose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The -H option only exists in GMT>=6.7.0, so need to check the current GMT version, and raise an exception if GMT 6.5/6.6 is used and no_font_scaling=True.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Plan to work on this tomorrow (Friday) afternoon.

Comment thread pygmt/src/colorbar.py Resolved
Comment thread pygmt/src/colorbar.py Resolved
@seisman

seisman commented Aug 24, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are: In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

After thinking it twice, I agree that font_scaling=True as the default is confusing. So let's use no_font_scaling.

Actually, I wonder if we should have the default to be no font scaling. From what I hear, the font scaling feature has confused users for a few years, and people may prefer no font scaling as the default. So, what about having

  • font_scaling=False: The default. Translated to -H.
  • font_scaling=True: If users want such a feature. No -H.

I know it's inconsistent with the default GMT behavior, but I wonder if no font scaling is more frequently used.

@seisman

seisman commented Aug 24, 2026

Copy link
Copy Markdown
Member

maybe font_scaling with default to True

Hmmm. Seems we will have fun with double negatives here 😅. My understanding and thoughts so far are: In GMT, not using -H means the auto-scaling applies. Setting -H turns off the auto-scaling. Setting a flag in GMT without any argument translates in PyGMT to True. So H=True leads to "no auto-scaling is applied". Based on this, the alias for H should contain the "no", with the default False as then no no auto-scaling (i.e., auto-scaling) is applied 😆.

After thinking it twice, I agree that font_scaling=True as the default is confusing. So let's use no_font_scaling.

Actually, I wonder if we should have the default to be no font scaling. From what I hear, the font scaling feature has confused users for a few years, and people may prefer no font scaling as the default. So, what about having

  • font_scaling=False: The default. Translated to -H.
  • font_scaling=True: If users want such a feature. No -H.

I know it's inconsistent with the default GMT behavior, but I wonder if no font scaling is more frequently used.

Likely a bad idea, because -H requires GMT>=6.7.0, thus people with different GMT versions will see different default behavior. Let's use no_font_scaling=False as default.

Comment thread pygmt/src/colorbar.py Resolved
@seisman

seisman commented Nov 16, 2026

Copy link
Copy Markdown
Member

I prefer to have this PR merged in v0.20.0

@seisman seisman removed the feature Brand new feature label Nov 16, 2026
Comment thread pygmt/src/colorbar.py
Comment on lines +464 to +465
scaled based on the length of the colorbar following
:math:`\sqrt{colorbar\_length / 15}`. To set a desired fontsize use the GMT

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed "width" to "length" to better match with the aliases length and width. For +w, we partly used "width" and "height".

@yvonnefroehlich yvonnefroehlich changed the title WIP: Figure.colorbar: Add alias "no_font_scaling" for "-H" Figure.colorbar: Add alias "no_font_scaling" for "-H" Nov 21, 2026
@yvonnefroehlich yvonnefroehlich added the needs review This PR has higher priority and needs review. label Nov 21, 2026
@yvonnefroehlich yvonnefroehlich changed the title Figure.colorbar: Add alias "no_font_scaling" for "-H" Figure.colorbar: Add alias "no_font_scaling" for "H" Nov 21, 2026
@yvonnefroehlich yvonnefroehlich removed the needs review This PR has higher priority and needs review. label Nov 22, 2026
@yvonnefroehlich yvonnefroehlich mentioned this pull request Nov 22, 2026
13 of 38 tasks
@seisman
seisman merged commit c41f5a7 into main Nov 23, 2026
22 of 23 checks passed
@seisman
seisman deleted the add-alias-H-colorbar branch November 23, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants