Skip to content

POC: DOC: A note recommending to call pygmt.config after pygmt.Figure() - #4735

Draft
yvonnefroehlich wants to merge 5 commits into
mainfrom
add-note-config
Draft

POC: DOC: A note recommending to call pygmt.config after pygmt.Figure()#4735
yvonnefroehlich wants to merge 5 commits into
mainfrom
add-note-config

Conversation

@yvonnefroehlich

@yvonnefroehlich yvonnefroehlich commented Jul 19, 2026

Copy link
Copy Markdown
Member

Description of proposed changes

Related to several issues, e.g., #733, #4732.

Need to read about -H of colorbar available for GMT >=6.7.0 (as mentioned in https://forum.generic-mapping-tools.org/t/psscale-colorbar-and-its-label-font-size/6472/4?u=yvonnefroehlich) to see if this can be helpful for PyGMT also and whether we should at an aliasa for -H; related to #3041 -> PR #4783.

Preview: https://pygmt-dev--4735.org.readthedocs.build/en/4735/api/generated/pygmt.config.html

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 19, 2026
@yvonnefroehlich yvonnefroehlich self-assigned this Jul 19, 2026
@yvonnefroehlich yvonnefroehlich added the documentation Improvements or additions to documentation label Jul 19, 2026
@yvonnefroehlich yvonnefroehlich changed the title POC: ODC: Add note for need to call pygmt.config after setting up pygmt.Figure instance POC: DOC: Add note for need to call pygmt.config after setting up pygmt.Figure instance Jul 19, 2026
@yvonnefroehlich
yvonnefroehlich marked this pull request as draft July 19, 2026 11:53
Comment thread pygmt/src/config.py Outdated

.. note::

Currently, :class:`pygmt.config` needs to be called **after** setting

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.

Actually, the note only make sense when multiple Figure instances are created in one session.

@seisman seisman added the needs review This PR has higher priority and needs review. label Jul 20, 2026
Comment thread pygmt/src/config.py
.. note::

For GMT defaults to adjust the figure appearance, e.g., the font size,
:class:`pygmt.config` needs to be called **after** setting up the

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.

Maybe just say "it's recommended to call pygmt.config after ..."

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 the wording "global" and "local" are a little misleading. Perhaps we should call them "permanent" and "temporary" instead, similar to the wording we use for Figure.shift_origin.

We also need to document https://docs.generic-mapping-tools.org/dev/reference/features.html#gmt-modern-mode-hierarchical-levels, but it could be done in a separate PR.

@yvonnefroehlich yvonnefroehlich changed the title POC: DOC: Add note for need to call pygmt.config after setting up pygmt.Figure instance POC: DOC: A note recommending to call pygmt.config after pygmt.Figure() Jul 27, 2026
@seisman seisman removed the needs review This PR has higher priority and needs review. label Jul 29, 2026
Comment thread pygmt/src/config.py
Comment on lines 14 to 23
Change GMT default settings globally or locally.

Change GMT default settings globally::

pygmt.config(PARAMETER=value)

Change GMT default settings locally by using it as a context manager::

with pygmt.config(PARAMETER=value):
...

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 feel the wording "global" and "local" are a little misleading. Perhaps we should call them "permanent" and "temporary" instead

Meaning we need to update the docs (and likely some examples) make the formulations consistent?

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.

Yes, the word "global" gives users the wrong impression that it has a global effect, but actually it only affects the configurations of the current figure, current subplot, or current inset (xref: https://docs.generic-mapping-tools.org/dev/reference/features.html#gmt-modern-mode-hierarchical-levels), depending on where pygmt.config() is called.

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 agree, we need to document the behaviour more detailed and clearly.

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants