Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion doc/rst/source/explain_-B.rst_
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ but you may also split this into two separate invocations for clarity, i.e.,

| **-B**\ [**p**\|\ **s**][**x**\|\ **y**\|\ **z**][**+a**\ *angle*\|\ **n**\|\ **p**][**+e**\ [**l**\|\ **u**]][**+f**]\
[**+l**\|\ **L**\ *label*][**+p**\ *prefix*][**+s**\|\ **S**\ *seclabel*][**+u**\ *unit*]
| **-B**\ [**p**\|\ **s**][**x**\|\ **y**\|\ **z**]\ *intervals*
| **-B**\ [**p**\|\ **s**][**x**\|\ **y**\|\ **z**]\ [**00**\|\ **000**]\ *intervals*
| **-B0**

The following directives and modifiers can be appended to **-B** to control the Axes settings:

Expand Down Expand Up @@ -128,6 +129,13 @@ The following directives and modifiers can be appended to **-B** to control the
the horizontal and must be in the -90 <= *angle* <= 90 range. **+an** can be used as a shorthand for normal
(i.e., **+a**\ 90) [Default for y-axis] and **+ap** for parallel (i.e., **+a**\ 0) annotations [Default for
x-axis]. These defaults can be changed via :term:`MAP_ANNOT_ORTHO`.
- **0** This will suppress all annotations and tick marks. Useful when you want to plot a map without any
annotations, grid or ticks but still want to plot a frame using a line with set by :term:`MAP_FRAME_PEN`.
- **00** Plot a frame with annotations, ticks etc use a zero-width line to plot the frame (0-width lines are lines
that remain very thin regardless of the zoom level).
- **000** Plot annotations, ticks and grid lines (as choosed) but do **not** plot the frame lines. Note, this effect
is only visible with _png_ and _pdf_ formats and is not guaranteed to work when selecting only a subset of the
axes (e.g., **-B000ya30g30** is not working well).
- *intervals* to define the intervals for annotations and major tick spacing, minor tick spacing, and/or grid line
spacing. See :ref:`Intervals Specification <option_-B_int>` for the formatting associated with this modifier.

Expand Down
25 changes: 14 additions & 11 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -4971,26 +4971,29 @@ GMT_LOCAL int gmtinit_parse5_B_option (struct GMT_CTRL *GMT, char *in) {
GMT->current.map.frame.axis[GMT_Z].angle = 0.0; /* Default is plotting normal to axis for Z, i.e., will look horizontal on the plot */
GMT->current.map.frame.axis[GMT_Z].use_angle = true;
strncpy (text, &in[k], GMT_BUFSIZ-1); /* Make a copy of the input, starting after the leading -B[p|s][xyz] indicators */
gmt_handle5_plussign (GMT, text, GMT_AXIS_MODIFIERS, 0); /* Temporarily change any +<letter> except +L|l, +f, +p, +S|s, +u to ASCII 1 to avoid interference with +modifiers */
gmt_handle5_plussign(GMT, text, GMT_AXIS_MODIFIERS, 0); /* Temporarily change any +<letter> except +L|l, +f, +p, +S|s, +u to ASCII 1 to avoid interference with +modifiers */
k = 0; /* Start at beginning of text and look for first occurrence of +L|l, +e, +f, +p, +S|s or +u */
while (text[k] && !(text[k] == '+' && strchr (GMT_AXIS_MODIFIERS, text[k+1]))) k++;
while (text[k] && !(text[k] == '+' && strchr(GMT_AXIS_MODIFIERS, text[k+1]))) k++;
gmt_M_memset (orig_string, GMT_BUFSIZ, char);
strncpy (orig_string, text, k); /* orig_string now has the interval information */
gmt_handle5_plussign (GMT, orig_string, NULL, 1); /* Recover any non-modifier plus signs */
gmt_handle5_plussign(GMT, orig_string, NULL, 1); /* Recover any non-modifier plus signs */
if (text[k]) mod = &text[k]; /* mod points to the start of the modifier information in text*/
for (no = 0; no < 3; no++) { /* Process each axis separately */
if (!side[no]) continue; /* Except we did not specify this axis */
if (!side[no]) continue; /* Except we did not specify this axis */
if (no == GMT_Z) GMT->current.map.frame.drawz = true;
if (!text[0]) continue; /* Skip any empty format string */
if (text[0] == '0' && !text[1]) { /* Understand format '0' to mean "no annotation, ticks, or gridlines" */
GMT->current.map.frame.draw = true; /* But we do wish to draw the frame */
if (no == 0 && !strncmp(text, "000", 3)) { /* Understand format '000' to mean "no frame but keep annots, ticks etc" */
GMT->current.setting.map_frame_type = GMT_IS_PLAIN; /* A no-frame fancy would be super complicated */
GMT->current.setting.map_frame_pen.rgb[3] = 1.0; /* Since it is very hard to no plot the axis, just make it transparent. */
}
else if (text[0] == '0' && !text[1] || !strncmp(text, "00", 2)) { /* Understand format '00' to mean zero line width frame. */
GMT->current.map.frame.draw = true; /* But we do wish to draw the frame */
if (GMT->common.J.zactive) GMT->current.map.frame.drawz = true; /* Also brings z-axis into contention */
GMT->current.setting.map_frame_type = GMT_IS_PLAIN; /* Since checkerboard without intervals look stupid */
GMT->current.map.frame.set[no] = true; /* Since we want this axis drawn */
#ifdef B0_IS_NO_FRAME
GMT->current.map.frame.no_frame = true; /* Understand format '0' to mean "NO FRAME AT ALL" */
#endif
continue;
GMT->current.map.frame.set[no] = true; /* Since we want this axis drawn */
if (no == 0 && !strncmp(text, "00", 2))
GMT->current.setting.map_frame_pen.width = 0; /* Understand format '00' to mean "draw the frame with a 0 width line */
if (!text[1] || !text[2]) continue; /* Only -B0 or -B00*/
}

if (mod) { /* Process the given axis modifiers */
Expand Down
Loading