Repository navigation
Closed
Labels
feature requestNew feature wanted
Description
This issue serves as the central place for discussing and tracking the implementation of the pygmt.config class in PyGMT. The issue will be closed when the initial implementation is complete. Progress is tracked at PyGMT: Wrapping GMT modules.
Documentation
- GMT: https://docs.generic-mapping-tools.org/dev/gmt.conf.html
- GMT.jl: https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/gmtset
- PyGMT: https://www.pygmt.org/dev/api/generated/pygmt.config.html
GMT Parameters (via gmt set)
☑️: Implemented; ⬜: To be implemented/discussed; Strikethrough: Won't implement.
COLOR group
- ☑️
COLOR_BACKGROUND,COLOR_FOREGROUND,COLOR_CPT,COLOR_NAN,COLOR_MODEL - ☑️
COLOR_HSV_MIN_S,COLOR_HSV_MAX_S,COLOR_HSV_MIN_V,COLOR_HSV_MAX_V - ☑️
COLOR_SET
DIR group
- ☑️
DIR_CACHE,DIR_DATA,DIR_DCW,DIR_GSHHG
FONT group
- ☑️
FONT_ANNOT_PRIMARY,FONT_ANNOT_SECONDARY,FONT_HEADING,FONT_LABEL,FONT_LOGO,FONT_SUBTITLE,FONT_TAG,FONT_TITLE - ☑️ Special alias
FONT(sets all standard font parameters at once) - ☑️ Special alias
FONT_ANNOT(sets primary and secondary annotation fonts)
FORMAT group
- ☑️
FORMAT_CLOCK_IN,FORMAT_CLOCK_OUT,FORMAT_CLOCK_MAP - ☑️
FORMAT_DATE_IN,FORMAT_DATE_OUT,FORMAT_DATE_MAP - ☑️
FORMAT_GEO_OUT,FORMAT_GEO_MAP - ☑️
FORMAT_FLOAT_OUT,FORMAT_FLOAT_MAP - ☑️
FORMAT_TIME_PRIMARY_MAP,FORMAT_TIME_SECONDARY_MAP,FORMAT_TIME_STAMP - ☑️ Special alias
FORMAT_TIME_MAP(sets both primary and secondary time map formats)
GMT group
- ☑️
GMT_DATA_SERVER,GMT_DATA_SERVER_LIMIT,GMT_DATA_UPDATE_INTERVAL - ☑️
GMT_COMPATIBILITY,GMT_CUSTOM_LIBS,GMT_EXPORT_TYPE,GMT_EXTRAPOLATE_VAL - ☑️
GMT_FFT,GMT_GRAPHICS_DPU,GMT_GRAPHICS_FORMAT,GMT_HISTORY - ☑️
GMT_INTERPOLANT,GMT_LANGUAGE,GMT_MAX_CORES,GMT_THEME - ☑️
GMT_TRIANGULATE,GMT_VERBOSE
IO group
- ☑️
IO_COL_SEPARATOR,IO_FIRST_HEADER,IO_GRIDFILE_FORMAT,IO_GRIDFILE_SHORTHAND - ☑️
IO_HEADER,IO_HEADER_MARKER,IO_N_HEADER_RECS,IO_NAN_RECORDS - ☑️
IO_NC4_CHUNK_SIZE,IO_NC4_DEFLATION_LEVEL,IO_LONLAT_TOGGLE - ☑️
IO_SEGMENT_BINARY,IO_SEGMENT_MARKER
MAP group
- ☑️
MAP_ANNOT_MIN_ANGLE,MAP_ANNOT_MIN_SPACING,MAP_ANNOT_OBLIQUE - ☑️
MAP_ANNOT_OFFSET_PRIMARY,MAP_ANNOT_OFFSET_SECONDARY,MAP_ANNOT_ORTHO - ☑️ Special alias
MAP_ANNOT_OFFSET(sets both primary and secondary annotation offsets) - ☑️
MAP_DEFAULT_PEN,MAP_DEGREE_SYMBOL,MAP_EMBELLISHMENT_MODE - ☑️
MAP_FRAME_AXES,MAP_FRAME_PEN,MAP_FRAME_PERCENT,MAP_FRAME_TYPE,MAP_FRAME_WIDTH - ☑️
MAP_GRID_CROSS_SIZE_PRIMARY,MAP_GRID_CROSS_SIZE_SECONDARY - ☑️ Special alias
MAP_GRID_CROSS_SIZE(sets both primary and secondary grid cross sizes) - ☑️
MAP_GRID_PEN_PRIMARY,MAP_GRID_PEN_SECONDARY - ☑️ Special alias
MAP_GRID_PEN(sets both primary and secondary grid pens) - ☑️
MAP_HEADING_OFFSET,MAP_LABEL_MODE,MAP_LABEL_OFFSET,MAP_LINE_STEP - ☑️
MAP_LOGO,MAP_LOGO_POS,MAP_ORIGIN_X,MAP_ORIGIN_Y,MAP_POLAR_CAP - ☑️
MAP_SCALE_HEIGHT - ☑️
MAP_TICK_LENGTH_PRIMARY,MAP_TICK_LENGTH_SECONDARY - ☑️ Special alias
MAP_TICK_LENGTH(sets both primary and secondary tick lengths) - ☑️
MAP_TICK_PEN_PRIMARY,MAP_TICK_PEN_SECONDARY - ☑️ Special alias
MAP_TICK_PEN(sets both primary and secondary tick pens) - ☑️
MAP_TITLE_OFFSET,MAP_VECTOR_SHAPE
PROJ group
- ☑️
PROJ_AUX_LATITUDE,PROJ_DATUM,PROJ_ELLIPSOID,PROJ_GEODESIC - ☑️
PROJ_LENGTH_UNIT,PROJ_MEAN_RADIUS,PROJ_SCALE_FACTOR
PS group
- ☑️
PS_CHAR_ENCODING,PS_COLOR_MODEL,PS_COMMENTS,PS_IMAGE_COMPRESS - ☑️
PS_LINE_CAP,PS_LINE_JOIN,PS_MITER_LIMIT,PS_MEDIA,PS_PAGE_COLOR - ☑️
PS_PAGE_ORIENTATION,PS_SCALE_X,PS_SCALE_Y,PS_TRANSPARENCY : Not supported; use parameters ofPS_CONVERTpygmt.Figure.savefigorpygmt.Figure.showinstead.
TIME group
- ☑️
TIME_EPOCH,TIME_IS_INTERVAL,TIME_INTERVAL_FRACTION,TIME_LEAP_SECONDS - ☑️
TIME_REPORT,TIME_UNIT,TIME_WEEK_START,TIME_Y2K_OFFSET_YEAR
Notes on Usage
pygmt.configcan be used in two modes: global (pygmt.config(PARAMETER=value)) or local (as a context manager withwith pygmt.config(PARAMETER=value): ...), where local mode automatically reverts settings to their previous values on exit.- The class exposes a manually crafted
__signature__to enable tab autocompletion for all supported GMT parameter keywords in interactive environments. - Special alias keywords (e.g.,
FONT,FONT_ANNOT,MAP_GRID_PEN) expand to multiple underlying GMT parameters and are handled via the_special_keywordsmapping. PS_CONVERTraises aSyntaxWarningand is silently ignored; conversion options should instead be passed topygmt.Figure.savefigorpygmt.Figure.show.pygmt.configwraps the GMTsetmodule internally (not a standalone GMT module with its own option flags).
Linked Pull Requests
- Initial feature implementation – Add pygmt.config() to change gmt defaults locally and globally #293
- Handle special parameters without defaults – Handle setting special parameters without default settings for config #411
- Add tutorial for
pygmt.config– Add tutorial for pygmt.config #482 - Add a gallery example demonstrating global vs. local (context manager) use of
pygmt.configto change map appearance (e.g., font sizes, frame type, tick lengths)
Related Issues and Discussions
pygmt.configis the PyGMT equivalent of GMT'sgmtsetcommand; it is commonly used at the start of a script or insidewithblocks to temporarily adjust map styling.- All other PyGMT wrappers that accept
--PAR=value-style GMT configuration overrides direct users topygmt.configinstead, so it plays a foundational role in the API. - The context manager pattern (
with pygmt.config(...):) is especially useful for producing multi-panel figures where individual panels need different font or pen settings without affecting the rest of the figure.
Metadata
Metadata
Assignees
Labels
feature requestNew feature wanted
Type
Projects
- StatusShow more project fieldsNo status
Activity
[-]Wrapper: Description of the module[/-][+]pygmt.config: Change GMT default settings globally or locally[/+]