Skip to content

Discussion: Improve -B for GMT 6 via long-format options #254

Open
@PaulWessel

Description

@PaulWessel

The complicated -B option has been with us since GMT 1. In GMT 5 we broke it up into several -B options that set different aspects of basemap specifications. However, it remains a very busy and unclear option. Let us see what needs to be set when a basemap is required in GMT:

1. The Canvas/Frame

  • Which axes to plot and how (via combination of codes WESNwesnlrbtZzu) [Default is MAP_FRAME_AXES]
  • Optionally paint canvas with uniform color (via +gfill) [No fill]
  • Optionally add plot title (via +t"my title") [no title]
  • Optionally suppress all frames and annotations (via +n)
  • For geographically oblique gridlines from another pole (via +olon/lat) [North pole; Rare usage]
  • For 3-D plots, we may wish to outline the 3-D box and see x-z, y-z gridlines, if selected (via +b) [no box]

2. Axes

Each of the axes we selected have many sub-settings. Furthermore, there are potentially two separate annotation/tick/gridline systems per axis: p - primary (Default, closest to axis) and s - secondary (farther from axis). Each system has many settings:

  • annotation interval (a)
  • tick interval (f)
  • gridline interval (g)
  • annotation prefix prepended to annotations (+p)
  • annotation unit appended to annotations (+u)
  • Axis label (+l|L)
  • Secondary axis label (+s|S) if different

3. Intervals

  • Intervals (e.g., annotation, tick, gridline) have settings too. By default they are placed at integer multiples of the given interval, but this placement can be phase-shifted by adding +|-phase [0].
  • Intervals take units and these may scale the interval but may also imply how numbers might be formatted (mostly applies to time axes).
  • Some intervals can be given as multiples or fractions of pi which means the pi symbol (and factors/fractions) are used in the annotations.
  • For log10 axis the intervals can be 1,2,3 or even negative; codes p and l imply different formatting.
  • For power axis code p implies different formatting.
  • For custom annotations a c is given instead of a,f,g (the file will have these settings).

Draft proposal for discussion:

Introduce additional long-format --option=* options to clarify how to give basemap specifics. They do not replace -B but can be used instead of -B. Like the other long-format options (#230) they will be available to both classic and modern mode.

  1. Canvas/frame:
  • --frame=|none[+fill=fill][+pole=lon/lat]
  • Break out separate --title=title
  1. Axis: (below, int can be none, auto, a numerical value with optional appended unit character, or name of file with custom annotations, tickmarks, and gridspacings)
    The first set apply to the primary (or only) axes system:
  • --annotations=int[+phase=phase][+prefix=txt][+unit=unit]
  • --ticks=int[+unit=unit][+phase=phase]
  • --gridlines=int[+unit=unit][+phase=phase] Default is none

The second set apply to the secondary axes system:

  • --secondary-annotations=int[+phase=phase][+prefix=txt][+unit=unit]
  • --secondary-ticks=int[+unit=unit][+phase=phase]
  • --secondary-gridlines=int[+unit=unit][+phase=phase] Default is none

There is only one label per axis but the E, N, U axes could have an "other" label:

  • --xlabel=xlabel
  • --ylabel=ylabel
  • --zlabel=zlabel
  • --other-xlabel=xlabel
  • --other-ylabel=ylabel
  • --other-zlabel=zlabel

The labels are given their own long option per axis to avoid difficulties in parsing free-form text separated by slashes (which could be part of the text); this is also why --title is a separate option.

The defaults are the same as before but needs a trigger --frame=default (like -Baf is needed today):

--frame=<MAP_FRAME_AXES>
--annotations=auto
--ticks=auto
--gridlines=none

There is some duplications here: --frame=none is the same as --annotations=none --ticks=none
A few simple examples:

	-Baf 
	-BWSne+gred -Baf
	-Bx30f10g5 -By2f1
	-B+glightgray+t"My plot" -Bxaf+l"X-axis" -Byaf+l"Y-axis"

would become

	--frame=default
	--frame=WSen+fill=red
	--annotations=30/2 --ticks=10/1 --gridlines=5/none
	--frame=default+fill=lightgray --xlabel="X-axis" --ylabel="Y-axis" --title="My plot"

Pre-parsing of these long-format options in gmt_init_module will result in a series of corresponding short -B options that the standard GMT parser can handle.

Note that external interfaces may break these down further (e.g., 'x-annotations', [1 3 15 19]) but can then concatenate these separate axis settings to the required --annotations=argument format.

Please give feedback on the chosen long-options and suggest improvements. The goal is to converge on the right set of long-format options and house the parsing of these in the C API and thus relieve the external interfaces from doing tedious parsing when preparing calls to GMT via GMT_Call_Module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionTopics for longer discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions