Skip to content

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

Open
yvonnefroehlich wants to merge 8 commits into
mainfrom
add-alias-H-colorbar
Open

WIP: Figure.colorbar: Add alias "no_font_scaling" for "-H"#4783
yvonnefroehlich wants to merge 8 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

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 Outdated
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.

Comment thread pygmt/src/colorbar.py Outdated
Comment thread pygmt/src/colorbar.py Outdated
yvonnefroehlich and others added 4 commits August 23, 2026 14:11
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@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
Comment on lines 297 to +308
.. note::
For GMT >=6.5.0, the fontsizes of the colorbar x-label, x-annotations,
and y-label are scaled based on the width of the colorbar following
:math:`\sqrt{colorbar\_width / 15}`. To set a desired fontsize via the
By default, the fontsizes of the colorbar annotations, label, and unit
are scaled based on the width of the colorbar following
:math:`\sqrt{colorbar\_width / 15}`. To set a desired fontsize use the
GMT default parameters :gmt-term:`FONT_ANNOT_PRIMARY`,
:gmt-term:`FONT_ANNOT_SECONDARY`, and :gmt-term:`FONT_LABEL` (or jointly
:gmt-term:`FONT`) users have to divide the desired fontsize by the value
calculated with the formula given above before passing it to the default
parameters. To only affect fontsizes related to the colorbar, the
defaults can be changed locally only using ``with pygmt.config(...):``.
:gmt-term:`FONT`)
For GMT >=6.7.0, users should use ``no_font_scaling = True`` to turn off
the automatic fontsize scaling.
For GMT 6.5.0 - 6.6.0, users have to divide the desired fontsize by the
value calculated with the formula given above before passing it to the
default parameters.

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.

I feel this note can be moved to the docstrings for no_font_scaling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature feature Brand new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants