Skip to content

Frame/Axis classes for frame settings to wrap GMT's -B option #4588

@seisman

Description

@seisman

Summary

This issue tracks the implementation of Frame and Axis classes in PyGMT as a structured wrapper around GMT’s -B option. The goal is to provide a Pythonic API for frame settings while preserving compatibility with existing frame usage.

Documentation

Motivation

GMT’s -B syntax is powerful but hard to read and discover in Python code. For example:

frame=["WStr+tTitle", "xa2f1g2+lxlabel", "ya5f1g5+lylabel"]

A structured API would improve readability, discoverability, validation, testing, and documentation. We decide to implement two classes, Frame and Axis, to control the frame and axis settings. An example usage is like below:

from pygmt.params import Axis, Frame

frame = Frame(
    axes="WStr",
    title="Title",
    xaxis=Axis(annot=2, tick=1, grid=2, label="xlabel"),
    yaxis=Axis(annot=5, tick=1, grid=5, label="ylabel"),
)

Checklist

Axis

The GMT CLI syntax is

-B[p|s][x|y|z]intervals[+aangle|n|p][+e[l|u]][+f][+l|Llabel][+pprefix][+s|Sseclabel][+uunit]

in which intervals is in the form of [a|f|g][stride][phase][unit].

In GMT, there are primary and secondary x-, y-, and z-axis.

Frame

The GMT CLI syntax is:

-B[axes][+b][+gfill][+i[val]][+n][+olon/lat][+ssubtitle][+ttitle][+w[pen]][+xfill][+yfill][+zfill]

Other use cases

Related PRs

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureBrand new feature

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions