From 9573f9a320c79fadab3f3b90cc4002bbf2894d87 Mon Sep 17 00:00:00 2001 From: chuan Date: Sun, 25 Jan 2026 22:47:17 +0800 Subject: [PATCH] Correctly setting the WrbNZ configuration. --- src/subplot.c | 60 +++++++++++++++------------- test/psbasemap/subplot_south_pole.sh | 8 ++++ 2 files changed, 40 insertions(+), 28 deletions(-) create mode 100755 test/psbasemap/subplot_south_pole.sh diff --git a/src/subplot.c b/src/subplot.c index 32e9e7d5ecf..563ef9ef545 100644 --- a/src/subplot.c +++ b/src/subplot.c @@ -772,34 +772,38 @@ static int parse (struct GMT_CTRL *GMT, struct SUBPLOT_CTRL *Ctrl, struct GMT_OP } } if (!Bframe) { /* No override, examine the default frame setting instead */ - gmt_set_undefined_axes (GMT, true); /* We cannot have MAP_FRAME_AXES=auto in subplot during -B parsing, so do the update now */ - if (Ctrl->S[GMT_X].active) /* Automatic selection of row sides via -Sr, so set to SN */ - strcpy (Ctrl->S[GMT_X].axes, "SN"); - else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ - if (strchr (GMT->current.setting.map_frame_axes, 'S')) Ctrl->S[GMT_X].axes[px++] = 'S'; - else if (strchr (GMT->current.setting.map_frame_axes, 's')) Ctrl->S[GMT_X].axes[px++] = 's'; - else if (strchr (GMT->current.setting.map_frame_axes, 'b')) Ctrl->S[GMT_X].axes[px++] = 'b'; - if (strchr (GMT->current.setting.map_frame_axes, 'N')) Ctrl->S[GMT_X].axes[px++] = 'N'; - else if (strchr (GMT->current.setting.map_frame_axes, 'n')) Ctrl->S[GMT_X].axes[px++] = 'n'; - else if (strchr (GMT->current.setting.map_frame_axes, 't')) Ctrl->S[GMT_X].axes[px++] = 't'; - } - if (Ctrl->S[GMT_Y].active) /* Automatic selection of column sides via -Sc, so set to WE */ - strcpy (Ctrl->S[GMT_Y].axes, "WE"); - else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ - if (strchr (GMT->current.setting.map_frame_axes, 'W')) Ctrl->S[GMT_Y].axes[py++] = 'W'; - else if (strchr (GMT->current.setting.map_frame_axes, 'w')) Ctrl->S[GMT_Y].axes[py++] = 'w'; - else if (strchr (GMT->current.setting.map_frame_axes, 'l')) Ctrl->S[GMT_Y].axes[py++] = 'l'; - if (strchr (GMT->current.setting.map_frame_axes, 'E')) Ctrl->S[GMT_Y].axes[py++] = 'E'; - else if (strchr (GMT->current.setting.map_frame_axes, 'e')) Ctrl->S[GMT_Y].axes[py++] = 'e'; - else if (strchr (GMT->current.setting.map_frame_axes, 'r')) Ctrl->S[GMT_Y].axes[py++] = 'r'; - } - /* Update MAP_FRAME_AXES for this subplot settings */ - if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) { - char axes[GMT_LEN32] = {""}; - strcpy (axes, Ctrl->S[GMT_X].axes); - strcat (axes, Ctrl->S[GMT_Y].axes); - strcat (axes, "Z"); - gmtlib_setparameter (GMT, "MAP_FRAME_AXES", axes, true); + bool is_polar_or_azim = false; + gmt_set_undefined_axes (GMT, true); /* Don't set MAP_FRAME_AXES=auto in subplot during -B parsing */ + if (GMT->current.proj.projection == GMT_POLAR || (gmt_M_is_azimuthal (GMT) && doubleAlmostEqual (GMT->current.proj.pars[1], -90.0))) is_polar_or_azim = true; + if (!is_polar_or_azim) { /* Only override axes for non-polar/non-azimuthal projections */ + if (Ctrl->S[GMT_X].active) /* Automatic selection of row sides via -Sr, so set to SN */ + strcpy (Ctrl->S[GMT_X].axes, "SN"); + else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ + if (strchr (GMT->current.setting.map_frame_axes, 'S')) Ctrl->S[GMT_X].axes[px++] = 'S'; + else if (strchr (GMT->current.setting.map_frame_axes, 's')) Ctrl->S[GMT_X].axes[px++] = 's'; + else if (strchr (GMT->current.setting.map_frame_axes, 'b')) Ctrl->S[GMT_X].axes[px++] = 'b'; + if (strchr (GMT->current.setting.map_frame_axes, 'N')) Ctrl->S[GMT_X].axes[px++] = 'N'; + else if (strchr (GMT->current.setting.map_frame_axes, 'n')) Ctrl->S[GMT_X].axes[px++] = 'n'; + else if (strchr (GMT->current.setting.map_frame_axes, 't')) Ctrl->S[GMT_X].axes[px++] = 't'; + } + if (Ctrl->S[GMT_Y].active) /* Automatic selection of column sides via -Sc, so set to WE */ + strcpy (Ctrl->S[GMT_Y].axes, "WE"); + else { /* Extract what the MAP_FRAME_AXES has for this axis instead */ + if (strchr (GMT->current.setting.map_frame_axes, 'W')) Ctrl->S[GMT_Y].axes[py++] = 'W'; + else if (strchr (GMT->current.setting.map_frame_axes, 'w')) Ctrl->S[GMT_Y].axes[py++] = 'w'; + else if (strchr (GMT->current.setting.map_frame_axes, 'l')) Ctrl->S[GMT_Y].axes[py++] = 'l'; + if (strchr (GMT->current.setting.map_frame_axes, 'E')) Ctrl->S[GMT_Y].axes[py++] = 'E'; + else if (strchr (GMT->current.setting.map_frame_axes, 'e')) Ctrl->S[GMT_Y].axes[py++] = 'e'; + else if (strchr (GMT->current.setting.map_frame_axes, 'r')) Ctrl->S[GMT_Y].axes[py++] = 'r'; + } + /* Update MAP_FRAME_AXES for this subplot settings */ + if (!strcmp (GMT->current.setting.map_frame_axes, "auto")) { + char axes[GMT_LEN32] = {""}; + strcpy (axes, Ctrl->S[GMT_X].axes); + strcat (axes, Ctrl->S[GMT_Y].axes); + strcat (axes, "Z"); + gmtlib_setparameter (GMT, "MAP_FRAME_AXES", axes, true); + } } } if (Ctrl->S[GMT_X].b == NULL) Ctrl->S[GMT_X].b = strdup ("af"); /* Default is -Baf if not set */ diff --git a/test/psbasemap/subplot_south_pole.sh b/test/psbasemap/subplot_south_pole.sh new file mode 100755 index 00000000000..4586babf06f --- /dev/null +++ b/test/psbasemap/subplot_south_pole.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Test South Pole longitude annotations in subplots +gmt begin subplot_south_pole ps + gmt subplot begin 1x2 -Fs10c -BWSNE -Ba30f30g30 -M15p -X1.5c + gmt basemap -R-180/180/60/90 -JS0/90/? -c -B+t"North" + gmt basemap -R-180/180/-90/-60 -JS0/-90/? -c -B+t"South" + gmt subplot end +gmt end show