From 3d75cf7db81c637f844c9c8d185c2dd33d53bae9 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Wed, 11 Jun 2025 18:30:05 +0100 Subject: [PATCH 1/5] Start expanding the -B0 option. --- src/gmt_init.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index aaf66cb25fe..347498ea5c2 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -4979,17 +4979,20 @@ GMT_LOCAL int gmtinit_parse5_B_option (struct GMT_CTRL *GMT, char *in) { 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" */ + if (text[0] == '0' && !text[1] || !strcmp(text, "00")) { /* 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 (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 + if (no == 0 && !strcmp(text, "00")) + GMT->current.setting.map_frame_pen.width = 0; /* Understand format '00' to mean "draw the frame with a 0 width line */ + continue; + } + else if (!strcmp(text, "000")) { + GMT->current.map.frame.no_frame = true; /* Understand format '000' to mean "NO FRAME AT ALL" */ continue; } From 454b639c7b01b2321968c74f29316298b3feaf6f Mon Sep 17 00:00:00 2001 From: Joaquim Date: Thu, 12 Jun 2025 00:20:54 +0100 Subject: [PATCH 2/5] A still non-working change --- src/gmt_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 347498ea5c2..f3f55aa25e2 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -4991,8 +4991,10 @@ GMT_LOCAL int gmtinit_parse5_B_option (struct GMT_CTRL *GMT, char *in) { GMT->current.setting.map_frame_pen.width = 0; /* Understand format '00' to mean "draw the frame with a 0 width line */ continue; } - else if (!strcmp(text, "000")) { - GMT->current.map.frame.no_frame = true; /* Understand format '000' to mean "NO FRAME AT ALL" */ + else if (no == 0 && !strncmp(text, "000", 3)) { + //GMT->current.map.frame.no_frame = true; /* Understand format '000' to mean "NO FRAME AT ALL" */ + GMT->current.setting.map_frame_type = GMT_IS_PLAIN; /* A no-frame fancy would be super complicated */ + GMT->current.setting.ps_transparency = 100; /* Understand format '000' to mean "no frame but keep annots, ticks etc" */ continue; } From 3eafe86b042bf5fd866bf0e37199eaa06fcf0864 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Mon, 16 Jun 2025 21:05:37 +0100 Subject: [PATCH 3/5] Let -B00[...] and -B000<...> do plot a zero width frame or no frame at all (but annots yes). Addresses discussion in #8740 --- src/gmt_init.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 1b765b4390d..b5539f1bb81 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -4971,31 +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 + 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 + 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 (no == GMT_Z) GMT->current.map.frame.drawz = true; if (!text[0]) continue; /* Skip any empty format string */ - if (text[0] == '0' && !text[1] || !strcmp(text, "00")) { /* 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 */ - if (no == 0 && !strcmp(text, "00")) + 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 */ - continue; - } - else if (no == 0 && !strncmp(text, "000", 3)) { - //GMT->current.map.frame.no_frame = true; /* Understand format '000' to mean "NO FRAME AT ALL" */ - GMT->current.setting.map_frame_type = GMT_IS_PLAIN; /* A no-frame fancy would be super complicated */ - GMT->current.setting.ps_transparency = 100; /* Understand format '000' to mean "no frame but keep annots, ticks etc" */ - continue; + if (!text[1] || !text[2]) continue; /* Only -B0 or -B00*/ } if (mod) { /* Process the given axis modifiers */ From 38d7184c21949ffabedd141f77d1f603ec2aab26 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Tue, 17 Jun 2025 01:09:45 +0100 Subject: [PATCH 4/5] Document the new -B0 forms --- doc/rst/source/explain_-B.rst_ | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/rst/source/explain_-B.rst_ b/doc/rst/source/explain_-B.rst_ index 97af0cad816..30d05fc9696 100644 --- a/doc/rst/source/explain_-B.rst_ +++ b/doc/rst/source/explain_-B.rst_ @@ -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: @@ -128,6 +129,10 @@ 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. +- **000** Plot annotations, ticks and grid lines (as choosed) but do **not** plot the frame lines. - *intervals* to define the intervals for annotations and major tick spacing, minor tick spacing, and/or grid line spacing. See :ref:`Intervals Specification ` for the formatting associated with this modifier. From 070048ee4ece4e106d829a915f40bd9cfbcc6678 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Tue, 17 Jun 2025 11:36:37 +0100 Subject: [PATCH 5/5] Add a few details. --- doc/rst/source/explain_-B.rst_ | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/rst/source/explain_-B.rst_ b/doc/rst/source/explain_-B.rst_ index 30d05fc9696..4ba276dad89 100644 --- a/doc/rst/source/explain_-B.rst_ +++ b/doc/rst/source/explain_-B.rst_ @@ -131,8 +131,11 @@ The following directives and modifiers can be appended to **-B** to control the 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. -- **000** Plot annotations, ticks and grid lines (as choosed) but do **not** plot the frame lines. +- **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 ` for the formatting associated with this modifier.