Skip to content

Figure.psconvert: Convert [E]PS file(s) to other formats using Ghostscript #4563

Closed

Description

@seisman

This issue serves as the central place for discussing and tracking the implementation of the Figure.psconvert method in PyGMT. The issue will be closed when the initial implementation is complete. Progress is tracked at PyGMT: Wrapping GMT modules.

Documentation

GMT Option Flags and Modifiers

☑️: Implemented; ⬜: To be implemented/discussed; Strikethrough: Won't implement.

  • <psfiles>
  • -A[+r][+u]
  • -C: gs_option
  • -D<dir>
  • -E: dpi
  • -F: prefix
  • -G: gs_path
  • -H<scale>
  • -I[+m<margins>][+s[m]<width>[/<height>]][+S<scale>]]
  • -L<list>
  • -Mb|f<psfile>
  • -N[+f<fade>][+g<backfill>][+k<fadefill>][+p[<pen>]]]
  • -P
  • -Q[g|p|t]1|2|4]
  • -S
  • -Tb|e|E|f|F|g|G|j|m|s|t[+m][+q<quality>]]
  • -V: verbose
  • -W[+a<mode>[<alt>]][+c][+f<minfade>/<maxfade>][+g][+k][+l<lodmin>/<lodmax>][+n<name>][+o<folder>][+t<title>][+u<URL>]]
  • -Z
  • -!
  • --PAR=<value>: Use pygmt.config instead.

Notes on Input Formats

  • Figure.psconvert is a method on pygmt.Figure; it converts the active figure's internal PostScript to the requested format using Ghostscript.
  • If no active figure exists, an error is raised.
  • The prefix parameter must be a non-empty string pointing to an existing directory; the method raises FileNotFoundError if the parent directory does not exist.
  • The output format is determined by fmt (-T); multiple formats can be combined (e.g., fmt="ef" produces both EPS and PDF).
  • crop=True (default) trims whitespace around the figure; append "+u" to also strip the GMT timestamp.

Linked Pull Requests

Related Issues and Discussions

  • Figure.psconvert is called implicitly by Figure.savefig; users who need more control over Ghostscript options should call Figure.psconvert directly.
  • The anti_aliasing parameter (-Q) is useful when producing raster images for presentations or publications at lower DPI settings.
  • The -L (file list) and -Tf (multi-page PDF) combination is the standard GMT approach for assembling a series of figures into a single PDF document.
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

    feature request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions