GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PS_CONVERT has no effect when using Figure.show/Figure.savefig/Figure.psconvert · Issue #4256 · GenericMappingTools/pygmt

PS_CONVERT has no effect when using Figure.show/Figure.savefig/Figure.psconvert #4256

New issue
Copy link
New issue
Copy link
Closed
#4342
Closed
PS_CONVERT has no effect when using Figure.show/Figure.savefig/Figure.psconvert#4256
#4342
Copy link
Labels
enhancementImproving an existing feature
Milestone
0.19.0

Description

@seisman
seisman
opened on Dec 8, 2025
Issue body actions

Description of the problem

PS_CONVERT is a GMT configuration parameter that can store a comma-separate list of options to use when calling psconvert implicitely when gmt end is called. The GMT documentation is at https://docs.generic-mapping-tools.org/6.6/gmt.conf.html#term-PS_CONVERT.

Comma-separated list of optional module arguments that we should supply when psconvert is called implicitly under modern mode [A]. Ignored when psconvert is called on the command line explicitly. The option arguments must be listed without their leading option hyphen.

In PyGMT, Figure.show/Figure.savefig calls psconvert internally, so this option has no effect, which is expected according to the GMT documentation. As a workaround, we can explicitely add these options when calling Figure.show/Figure.savefig, but it's a little tedious.

Possible solutions are:

  1. Document that PS_CONVERT is ignored in PyGMT.
  2. In Figure.psconvert, parse the values of PS_CONVERT and append them to the argument list when calling psconvert.
  3. Thinking about if there is a more Pythonic and elegant way to implement the same feature.

Solution 2 is not that hard to implement, but need time to think about solution 3.

Minimal Complete Verifiable Example

import pygmt
pygmt.config(PS_CONVERT="C-I/home/xxx/.gmt")
fig = pygmt.Figure()
fig.basemap(region="g", projection="H8c", frame=True)
fig.savefig("map.png", verbose="d")

Full error message

pygmt-session [DEBUG]: Revised options: -A -Fmap -Qg2 -Qt2 -Tg -Vd
psconvert [DEBUG]: Ghostscript executable full name:
psconvert [DEBUG]: gmt_run_process_get_first_line: Pass to popen: [gs --version 2> /dev/null]
psconvert [DEBUG]: gs --version 2> /dev/null was successful
psconvert [DEBUG]: Ghostscript version: 10.06.0

Options in PS_CONVERT are not shown in the first line of the debugging message.

The bug was originally found in #3220.

Activity

  1. seisman
    added
    bugSomething isn't working
    on Dec 8, 2025
  2. seisman
    added
    bugSomething isn't working
    and removed
    bugSomething isn't working
    on Jan 12, 2026
  3. seisman commented on Jan 12, 2026

    @seisman
    seisman
    on Jan 12, 2026
    MemberAuthor
    More actions

    Thanks @Chuan1937 for tackling this in PR #4342.

    After comparing Solutions 1 and 2, I prefer Solution 1.

    The argument of PS_CONVERT (e.g., pygmt.config(PS_CONVERT="C-I/home/xxx/.gmt,E300") is not readable and not Pythonic. Users have to read through the GMT documentation to understand its meaning. It also changes the global configuration, which may have side-effect.

    Instead of setting PS_CONVERT, user can set parameters when calling Figure.savefig/Figure.show, which is more readable and Pythonic:

    fig.savefig("map.png", gs_option="-I/home/xxx/.gmt", dpi=300)

    If the same parameters need to be reused, it's easy to define a dict and pass it to Figure.savefig/Figure.show when needed. E.g.,

    psconvert_kwdict = dict(gs_option="-I/home/xxx/.gmt", dpi=300)
    fig.savefig("map1.png", **psconvert_kwdict)
    fig.show(**psconvert_kwdict)
    Reacted by Xingchen He
  4. seisman commented on Jan 13, 2026

    @seisman
    seisman
    on Jan 13, 2026
    MemberAuthor
    More actions

    @GenericMappingTools/pygmt-maintainers Any comments?

  5. seisman
    added this to the 0.19.0 milestone on Jan 13, 2026
  6. weiji14 commented on Jan 13, 2026

    @weiji14
    weiji14
    on Jan 13, 2026
    Member
    More actions

    fig.savefig("map.png", gs_option="-I/home/xxx/.gmt", dpi=300)

    Using gs_option (i.e. -C in psconvert) sounds reasonable. Maybe we can also remove or comment out PS_CONVERT from the autocomplete at

    pygmt/pygmt/src/config.py

    Line 138 in b1d4bd7

    "PS_CONVERT",

    so that people don't use it accidentally? Or is there a way still to make the PS_CONVERT config work if used globally?

  7. seisman commented on Jan 13, 2026

    @seisman
    seisman
    on Jan 13, 2026
    MemberAuthor
    More actions

    Using gs_option (i.e. -C in psconvert) sounds reasonable. Maybe we can also remove or comment out PS_CONVERT from the autocomplete at so that people don't use it accidentally?

    With Solution 1, I think we should do:

    • Add a note that PS_CONVERT is not supported in the pygmt.config documentation [Already done in Add a note/warning that PS_CONVERT is not supported #4342]
    • Raise a warning if pygmt.config(PS_CONVERT=...) is used.
    • Remove PS_CONVERT from autocomplete

    Or is there a way still to make the PS_CONVERT config work if used globally?

    In GMT CLI, PS_CONVERT is only used when calling gmt end. To make it work in PyGMT, we have to parse the value of PS_CONVERT and pass the CLI options psconvert when calling Figure.savefig/Figure.show. See the initial version in PR #4342

    pygmt/pygmt/src/psconvert.py

    Lines 146 to 166 in 26c0c6d

    # Check PS_CONVERT settings: PyGMT calls psconvert explicitly,
    # so inject default options here if the user didn't override them.
    if ps_convert_config := lib.get_default("PS_CONVERT"):
    for option in ps_convert_config.split(","):
    opt = option.strip()
    if not opt:
    continue
    # Validate option format: expect a single-character flag followed
    # by an optional value (e.g., "A", "E300").
    if not opt[0].isalpha():
    raise GMTValueError(
    opt,
    description="PS_CONVERT option",
    reason=(
    "Invalid PS_CONVERT configuration: each option must "
    "start with a letter flag followed by an optional value."
    ),
    )
    flag, value = opt[0], opt[1:]
    if flag not in aliasdict:
    aliasdict[flag] = value

    Reacted by Wei Ji
  8. weiji14 commented on Jan 13, 2026

    @weiji14
    weiji14
    on Jan 13, 2026
    Member
    More actions

    In GMT CLI, PS_CONVERT is only used when calling gmt end. To make it work in PyGMT, we have to parse the value of PS_CONVERT and pass the CLI options psconvert when calling Figure.savefig/Figure.show. See the initial version in PR #4342

    This chunk of code is a little trickier to understand/maintain. So would lean towards just raising a warning when PS_CONVERT is used as you suggested ^.

  9. seisman
    closed this as completedin #4342on Jan 13, 2026
  10. seisman
    added
    enhancementImproving an existing feature
    and removed
    bugSomething isn't working
    on Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImproving an existing feature

    Type

    No type

    Projects

    No projects

      Milestone

      • 0.19.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.