Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot/plot3d: Simplify the -A syntax to -Ax|y #8674

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 9 additions & 8 deletions doc/rst/source/explain_line_draw.rst_
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
**-A**\ [**m**\|\ **p**\|\ **x**\|\ **y**\|\ **r**\|\ **t**]
**-A**\ [**x**\|\ **y**]
By default, geographic line segments are drawn as great circle arcs by resampling
coarse input data along such arcs. To disable this sampling and draw them as
straight lines, use the |-A| flag. For Cartesian data, points are simply connected.
To adjust these behaviors, append a directive:

- **m** - Draw the line by first following a meridian, then a parallel.
- **p** - Start following a parallel, then a meridian. (This can be practical
to draw a line along parallels, for example).
- **r** - For polar projections, draw stair-case curves whose first move is along *r*.
- **t** - Same, but first move is along *theta*.
- **x** - For Cartesian data, draw stair-case curves that whose first move is along *x*.
- **y** - Same, but first move is along *y*.
- **x** - First follow *x*, then *y* for staircase curves.
- **y** - First follow *y*, then *x* for staircase curves.

Here, *x* and *y* have the following meanings:

- For Cartesian projections, *x* and *y* are the X- and Y-axis.
- For gragraphic projections, *x* and *y* are parallels and meridians.
- For polar projections, *x* and *y* are theta and radius.

**Note**: In :doc:`plot3d`, the |-A| option requires constant *z*-coordinates.
10 changes: 5 additions & 5 deletions doc/rst/source/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Synopsis

**gmt plot** [ *table* ] |-J|\ *parameters*
|SYN_OPT-Rz|
[ |-A|\ [**m**\|\ **p**\|\ **x**\|\ **y**\|\ **r**\|\ **t**] ]
[ |-A|\ [**x**\|\ **y**] ]
[ |SYN_OPT-B| ]
[ |-C|\ *cpt* ]
[ |-D|\ *dx*\ [/*dy*] ]
Expand Down Expand Up @@ -249,13 +249,13 @@ Optional Arguments
as column 2 (i.e., third) in any number of files having three columns. Each file may
contain any number of segments per file.
- **s** - Same but the two curves are given via separate pairs of tables [Default].

Several modifiers are at your disposal:

- **+g** - We use the *fill* set via |-G| to fill the areas where :math:`y_0(x)` exceeds
:math:`y_1(x)`. For the opposite case, append another *fill* here.
:math:`y_1(x)`. For the opposite case, append another *fill* here.
- **+l** - For the primary curve :math:`y_0(x)`, a legend label can be set via option
|SYN_OPT-l|. For a secondary label use this modifier to append the label.
|SYN_OPT-l|. For a secondary label use this modifier to append the label.
- **+p** - Specify a separate pen for drawing curve :math:`y_1(x)` [Default is same pen
as :math:`y_0(x)`]. See |-W| for specifying the pen for curve :math:`y_0(x)`.
- **+r** - Specify a pen to simply draw a line instead of a filled box in the legend, but
Expand Down Expand Up @@ -309,7 +309,7 @@ Optional Arguments
*width* = 0.25p, *color* = black, *style* = solid]. Modifiers can be used to change the
appearance of the line:

- **+c** - Determine how the color from the cpt file lookup is applied to symbol
- **+c** - Determine how the color from the cpt file lookup is applied to symbol
and|or fill. Append **l** to have the color of the line to be taken from the CPT (see
|-C|). If instead **f** is appended then the color from the cpt file is applied
to symbol fill. If no argument is given the we use the color for both pen and fill.
Expand Down
4 changes: 2 additions & 2 deletions doc/rst/source/plot3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Synopsis
**gmt plot3d** [ *table* ] |-J|\ *parameters*
|-Jz|\ \|\ **Z**\ *parameters*
|SYN_OPT-Rz|
[ |-A|\ [**m**\|\ **p**\|\ **x**\|\ **y**\|\ **r**\|\ **t**] ]
[ |-A|\ [**x**\|\ **y**] ]
[ |SYN_OPT-B| ]
[ |-C|\ *cpt* ]
[ |-D|\ *dx*/*dy*\ [/*dz*] ]
Expand Down Expand Up @@ -211,7 +211,7 @@ Optional Arguments
*width* = 0.25p, *color* = black, *style* = solid]. Modifiers can be used to change the
appearance of the line:

- **+c** - Determine how the color from the cpt file lookup is applied to symbol
- **+c** - Determine how the color from the cpt file lookup is applied to symbol
and|or fill. Append **l** to have the color of the line to be taken from the CPT (see
|-C|). If instead **f** is appended then the color from the cpt file is applied
to symbol fill. If no argument is given the we use the color for both pen and fill.
Expand Down
2 changes: 1 addition & 1 deletion doc/rst/source/psxy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Synopsis

**gmt psxy** [ *table* ] |-J|\ *parameters*
|SYN_OPT-Rz|
[ |-A|\ [**m**\|\ **p**\|\ **x**\|\ **y**\|\ **r**\|\ **t**] ]
[ |-A|\ [**x**\|\ **y**] ]
[ |SYN_OPT-B| ]
[ |-C|\ *cpt* ]
[ |-D|\ *dx*/*dy* ]
Expand Down
2 changes: 1 addition & 1 deletion doc/rst/source/psxyz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Synopsis
**gmt psxyz** [ *table* ] |-J|\ *parameters*
|-J|\ **z**\|\ **Z**\ *parameters*
|SYN_OPT-Rz|
[ |-A|\ [**m**\|\ **p**\|\ **x**\|\ **y**\|\ **r**\|\ **t**] ]
[ |-A|\ [**x**\|\ **y**] ]
[ |SYN_OPT-B| ]
[ |-C|\ *cpt* ]
[ |-D|\ *dx*/*dy*\ [/*dz*] ]
Expand Down
21 changes: 11 additions & 10 deletions src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

struct PSXY_CTRL {
bool no_RJ_needed; /* Special case of -T and no -B when -R -J is not required */
struct PSXY_A { /* -A[m|y|p|x|r|t<step>] */
struct PSXY_A { /* -A[x|y]] */
bool active;
unsigned int mode;
double step;
Expand Down Expand Up @@ -529,7 +529,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
const char *mod_name = &name[4]; /* To skip the leading gmt for usage messages */
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);

GMT_Usage (API, 0, "usage: %s [<table>] %s %s [-A[m|p|r|t|x|y]] [%s] [-C<cpt>] [-D<dx>/<dy>] [%s] [-F%s] [-G<fill>|+z] "
GMT_Usage (API, 0, "usage: %s [<table>] %s %s [-A[x|y]] [%s] [-C<cpt>] [-D<dx>/<dy>] [%s] [-F%s] [-G<fill>|+z] "
"[-H[<scale>]] [-I[<intens>]] %s[%s] [-M[c|s][+g<fill>][+l<seclabel>][+p<pen>][+r[<pen>]][+y[<level>]]] [-N[c|r]] %s%s [-S[<symbol>][<size>]] [%s] [%s] [-W[<pen>][<attr>]] [%s] [%s] "
"[-Z<value>|<file>[+t|T]] [%s] [%s] %s[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n",
name, GMT_J_OPT, GMT_Rgeoz_OPT, GMT_B_OPT, PSXY_E_OPT, GMT_SEGMENTIZE3, API->K_OPT, PLOT_L_OPT, API->O_OPT, API->P_OPT,
Expand All @@ -542,15 +542,15 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Message (API, GMT_TIME_NONE, " REQUIRED ARGUMENTS:\n");
GMT_Option (API, "<,J-Z,R");
GMT_Message (API, GMT_TIME_NONE, "\n OPTIONAL ARGUMENTS:\n");
GMT_Usage (API, 1, "\n-A[m|p|r|t|x|y]");
GMT_Usage (API, 1, "\n-A[x|y]");
GMT_Usage (API, -2, "Suppress drawing geographic line segments as great circle arcs, i.e., draw "
"straight lines instead. Six optional directives instead convert paths to staircase curves:");
GMT_Usage (API, 3, "m: First follow meridians, then parallels when connecting geographic points.");
GMT_Usage (API, 3, "p: First follow parallels, then meridians when connecting geographic point.");
GMT_Usage (API, 3, "r: First follow radius, then theta for staircase curves for Polar projection.");
GMT_Usage (API, 3, "t: First follow theta, then radius for staircase curves for Polar projection.");
GMT_Usage (API, 3, "x: First follow x, then y for staircase curves for Cartesian projections.");
GMT_Usage (API, 3, "y: First follow y, then x for staircase curves for Cartesian projections.");
"straight lines instead. Two optional directives instead convert paths to staircase curves:");
GMT_Usage (API, 3, "x: First follow x, then y for staircase curves.");
GMT_Usage (API, 3, "y: First follow y, then x for staircase curves.");
GMT_Usage (API, -2, "Here, x and y have the following meanings: "
"For Cartesian projections, x and y are the X- and Y-axis; "
"For gragraphic projections, x and y are parallels and meridians; "
"For polar projections, x and y are theta and radius.");
GMT_Option (API, "B-");
GMT_Usage (API, 1, "\n-C<cpt>|<color1>,<color2>[,<color3>,...]");
GMT_Usage (API, -2, "Assign symbol colors based on z-value in 3rd column. "
Expand Down Expand Up @@ -837,6 +837,7 @@ static int parse (struct GMT_CTRL *GMT, struct PSXY_CTRL *Ctrl, struct GMT_OPTIO

case 'A': /* Turn off draw_arc mode */
n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
/* There are 6 optional directives but only x|y are documented since 6.6.0 */
switch (opt->arg[0]) {
case 'm': case 'y': case 'r': Ctrl->A.mode = GMT_STAIRS_Y; break;
case 'p': case 'x': case 't': Ctrl->A.mode = GMT_STAIRS_X; break;
Expand Down
21 changes: 11 additions & 10 deletions src/psxyz.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/* Control structure for psxyz */

struct PSXYZ_CTRL {
struct PSXYZ_A { /* -A[m|y|p|x|r|t|step] */
struct PSXYZ_A { /* -A[x|y] */
bool active;
unsigned int mode;
double step;
Expand Down Expand Up @@ -173,7 +173,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
const char *mod_name = &name[4]; /* To skip the leading gmt for usage messages */
const char *T[2] = {" [-T]", ""};
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Usage (API, 0, "usage: %s [<table>] %s %s [%s] [%s] [-A[m|p|r|t|x|y]] [-C<cpt>] [-D<dx>/<dy>[/<dz>]] [-G<fill>] "
GMT_Usage (API, 0, "usage: %s [<table>] %s %s [%s] [%s] [-A[x|y]] [-C<cpt>] [-D<dx>/<dy>[/<dz>]] [-G<fill>] "
"[-H[<scale>]] [-I[<intens>]] %s [%s] [-N[c|r]] %s %s[-Q] [-S[<symbol>][<size>][/size_y]]%s [%s] [%s] [-W[<pen>][<attr>]] "
"[%s] [%s] [-Z<value>|<file>[+t|T]] [%s] [%s] %s[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n",
name, GMT_J_OPT, GMT_Rgeoz_OPT, GMT_B_OPT, GMT_Jz_OPT, API->K_OPT, PLOT_L_OPT, API->O_OPT, API->P_OPT,
Expand All @@ -187,15 +187,15 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Option (API, "<,J-Z,R3");
GMT_Message (API, GMT_TIME_NONE, "\n OPTIONAL ARGUMENTS:\n");
GMT_Option (API, "B-");
GMT_Usage (API, 1, "\n-A[m|p|r|t|x|y]");
GMT_Usage (API, 1, "\n-A[x|y]");
GMT_Usage (API, -2, "Suppress drawing geographic line segments as great circle arcs, i.e., draw "
"straight lines instead. Six optional directives instead convert paths to staircase curves:");
GMT_Usage (API, 3, "m: First follow meridians, then parallels when connecting geographic points.");
GMT_Usage (API, 3, "p: First follow parallels, then meridians when connecting geographic point.");
GMT_Usage (API, 3, "r: First follow radius, then theta for staircase curves for Polar projection.");
GMT_Usage (API, 3, "t: First follow theta, then radius for staircase curves for Polar projection.");
GMT_Usage (API, 3, "x: First follow x, then y for staircase curves for Cartesian projections.");
GMT_Usage (API, 3, "y: First follow y, then x for staircase curves for Cartesian projections.");
"straight lines instead. Two optional directives instead convert paths to staircase curves:");
GMT_Usage (API, 3, "x: First follow x, then y for staircase curves.");
GMT_Usage (API, 3, "y: First follow y, then x for staircase curves.");
GMT_Usage (API, -2, "Here, x and y have the following meanings: "
"For Cartesian projections, x and y are the X- and Y-axis; "
"For gragraphic projections, x and y are parallels and meridians; "
"For polar projections, x and y are theta and radius.");
GMT_Usage (API, 1, "\n-C<cpt>|<color1>,<color2>[,<color3>,...]");
GMT_Usage (API, -2, "Assign symbol colors based on z-value in 3rd column. "
"Note: requires -S. Without -S, %s excepts lines/polygons "
Expand Down Expand Up @@ -422,6 +422,7 @@ static int parse (struct GMT_CTRL *GMT, struct PSXYZ_CTRL *Ctrl, struct GMT_OPTI

case 'A': /* Turn off draw_arc mode */
n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
/* There are 6 optional directives but only x|y are documented since 6.6.0 */
switch (opt->arg[0]) {
case 'm': case 'y': case 'r': Ctrl->A.mode = GMT_STAIRS_Y; break;
case 'p': case 'x': case 't': Ctrl->A.mode = GMT_STAIRS_X; break;
Expand Down
2 changes: 1 addition & 1 deletion test/baseline/psxy.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 239f4bd18d38b222c7da4a1fa70bb7aa.dir
- md5: c597478c2dfc51aa340071f73df8731c.dir
nfiles: 142
path: psxy
hash: md5
2 changes: 1 addition & 1 deletion test/psxy/nojump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ cat << EOF > t.txt
115 -20
EOF
gmt psxy -R110/215/-27/20 -JM6i t.txt -Wfat,green -Baf -BWSne -A -P -K -Xc > $ps
gmt psxy -R -J t.txt -Wfat,green -Baf -BWSne -Ap -O -K -Y3.15i >> $ps
gmt psxy -R -J t.txt -Wfat,green -Baf -BWSne -Ax -O -K -Y3.15i >> $ps
gmt psxy -R -J t.txt -Wfat,green -Baf -BWSne -O -Y3.15i >> $ps
10 changes: 5 additions & 5 deletions test/psxy/polarcurves.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# test the -Ar|t line-resampling for polar projections
# test the -Ax|y line-resampling for polar projections
cat << EOF > t.txt
10 5
30 4
Expand All @@ -10,11 +10,11 @@ gmt begin polarcurves ps
gmt subplot set 0 -A"No -A"
gmt plot -W2p,red t.txt
gmt plot t.txt -Sc0.2c -Wthin
gmt subplot set 1 -A"-At: @~q@~, then r"
gmt plot -W2p,red -At t.txt
gmt subplot set 1 -A"-Ax: @~q@~, then r"
gmt plot -W2p,red -Ax t.txt
gmt plot t.txt -Sc0.2c -Wthin
gmt subplot set 2 -A"-Ar: r, then @~q@~"
gmt plot -W2p,red -Ar t.txt
gmt subplot set 2 -A"-Ay: r, then @~q@~"
gmt plot -W2p,red -Ay t.txt
gmt plot t.txt -Sc0.2c -Wthin
gmt subplot end
gmt end show
Loading