Skip to content

Commit b58fb7f

Browse files
committed
Alias straight_lines(A), close(L), position(D) for plot3d and plot
Added new aliases (mostly based on GMT.jl's), and fixed old docstring to remove short-form aliases. Since `plot3d` and `plot` are similar, we might as well fix both of them at the same time. Also keeping the unit tests consistent.
1 parent e38b3f9 commit b58fb7f

File tree

3 files changed

+60
-43
lines changed

3 files changed

+60
-43
lines changed

pygmt/base_plotting.py

+52-35
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,17 @@ def grdview(self, grid, **kwargs):
432432
@use_alias(
433433
R="region",
434434
J="projection",
435+
A="straight_lines",
435436
B="frame",
436-
S="style",
437+
C="cmap",
438+
D="position",
439+
E="error_bars",
437440
G="color",
441+
L="close",
442+
S="style",
438443
W="pen",
439444
i="columns",
440445
l="label",
441-
C="cmap",
442446
)
443447
@kwargs_to_strings(R="sequence", i="sequence_comma")
444448
def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
@@ -452,26 +456,26 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
452456
453457
Must provide either *data* or *x* and *y*.
454458
455-
If providing data through *x* and *y*, *color* (G) can be a 1d array
456-
that will be mapped to a colormap.
459+
If providing data through *x* and *y*, *color* can be a 1d array that
460+
will be mapped to a colormap.
457461
458-
If a symbol is selected and no symbol size given, then psxy will
462+
If a symbol is selected and no symbol size given, then plot will
459463
interpret the third column of the input data as symbol size. Symbols
460464
whose size is <= 0 are skipped. If no symbols are specified then the
461-
symbol code (see *S* below) must be present as last column in the
462-
input. If *S* is not used, a line connecting the data points will be
463-
drawn instead. To explicitly close polygons, use *L*. Select a fill
464-
with *G*. If *G* is set, *W* will control whether the polygon outline
465-
is drawn or not. If a symbol is selected, *G* and *W* determines the
466-
fill and outline/no outline, respectively.
465+
symbol code (see *symbol* below) must be present as last column in the
466+
input. If *symbol* is not used, a line connecting the data points will
467+
be drawn instead. To explicitly close polygons, use *close*. Select a
468+
fill with *color*. If *color* is set, *pen* will control whether the
469+
polygon outline is drawn or not. If a symbol is selected, *color* and
470+
*pen* determines the fill and outline/no outline, respectively.
467471
468472
Full option list at :gmt-docs:`plot.html`
469473
470474
{aliases}
471475
472476
Parameters
473477
----------
474-
x, y : float or 1d arrays
478+
x/y : float or 1d arrays
475479
The x and y coordinates, or arrays of x and y coordinates of the
476480
data points
477481
data : str or 2d array
@@ -488,25 +492,29 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
488492
depending on the style options chosen.
489493
{J}
490494
{R}
491-
A : bool or str
495+
straight_lines : bool or str
492496
``'[m|p|x|y]'``
493497
By default, geographic line segments are drawn as great circle
494-
arcs. To draw them as straight lines, use *A*.
498+
arcs. To draw them as straight lines, use *straight_lines*.
495499
{B}
496500
{CPT}
497-
D : str
501+
position : str
498502
``'dx/dy'``: Offset the plot symbol or line locations by the given
499503
amounts dx/dy.
500-
E : bool or str
504+
error_bars : bool or str
501505
``'[x|y|X|Y][+a][+cl|f][+n][+wcap][+ppen]'``.
502506
Draw symmetrical error bars.
503507
{G}
504-
S : str
508+
style : str
505509
Plot symbols (including vectors, pie slices, fronts, decorated or
506510
quoted lines).
507511
{W}
508512
{U}
509-
l : str
513+
columns : list or str
514+
``cols[+l][+sscale][+ooffset][,…][,t[word]]``
515+
Select input columns and transformations (0 is first column, t is
516+
trailing text, append word to read one word only).
517+
label : str
510518
Add a legend entry for the symbol or line being plotted.
511519
"""
512520
kwargs = self._preprocess(**kwargs)
@@ -551,13 +559,17 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
551559
J="projection",
552560
Jz="zscale",
553561
JZ="zsize",
562+
A="straight_lines",
554563
B="frame",
555-
S="style",
564+
C="cmap",
565+
D="position",
566+
E="error_bars",
556567
G="color",
568+
L="close",
569+
S="style",
557570
W="pen",
558571
i="columns",
559572
l="label",
560-
C="cmap",
561573
p="perspective",
562574
)
563575
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
@@ -567,23 +579,24 @@ def plot3d(
567579
"""
568580
Plot lines, polygons, and symbols in 3-D
569581
570-
Takes a matrix, (x,y,z) triplets, or a file name as input and plots lines,
571-
polygons, or symbols at those locations in 3-D.
582+
Takes a matrix, (x,y,z) triplets, or a file name as input and plots
583+
lines, polygons, or symbols at those locations in 3-D.
572584
573585
Must provide either *data* or *x*, *y* and *z*.
574586
575-
#If providing data through *x* and *y*, *color* (G) can be a 1d array
576-
#that will be mapped to a colormap.
587+
If providing data through *x*, *y* and *z*, *color* can be a 1d array
588+
that will be mapped to a colormap.
577589
578590
If a symbol is selected and no symbol size given, then plot3d will
579591
interpret the fourth column of the input data as symbol size. Symbols
580592
whose size is <= 0 are skipped. If no symbols are specified then the
581-
symbol code (see *S* below) must be present as last column in the
582-
input. If *S* is not used, a line connecting the data points will be
583-
drawn instead. To explicitly close polygons, use *L*. Select a fill
584-
with *G*. If *G* is set, *W* will control whether the polygon outline
585-
is drawn or not. If a symbol is selected, *G* and *W* determines the
586-
fill and outline/no outline, respectively.
593+
symbol code (see *style* below) must be present as last column in the
594+
input. If *style* is not used, a line connecting the data points will
595+
be drawn instead. To explicitly close polygons, use *close*. Select a
596+
fill
597+
with *color*. If *color* is set, *pen* will control whether the polygon
598+
outline is drawn or not. If a symbol is selected, *color* and *pen*
599+
determines the fill and outline/no outline, respectively.
587600
588601
Full option list at :gmt-docs:`plot3d.html`
589602
@@ -610,25 +623,29 @@ def plot3d(
610623
zscale/zsize : float or str
611624
Set z-axis scaling or z-axis size.
612625
{R}
613-
A : bool or str
626+
straight_lines : bool or str
614627
``'[m|p|x|y]'``
615628
By default, geographic line segments are drawn as great circle
616629
arcs. To draw them as straight lines, use *A*.
617630
{B}
618631
{CPT}
619-
D : str
632+
position : str
620633
``'dx/dy'``: Offset the plot symbol or line locations by the given
621634
amounts dx/dy.
622-
E : bool or str
635+
error_bars : bool or str
623636
``'[x|y|X|Y][+a][+cl|f][+n][+wcap][+ppen]'``.
624637
Draw symmetrical error bars.
625638
{G}
626-
S : str
639+
style : str
627640
Plot symbols (including vectors, pie slices, fronts, decorated or
628641
quoted lines).
629642
{W}
630643
{U}
631-
l : str
644+
columns : list or str
645+
``cols[+l][+sscale][+ooffset][,…][,t[word]]``
646+
Select input columns and transformations (0 is first column, t is
647+
trailing text, append word to read one word only).
648+
label : str
632649
Add a legend entry for the symbol or line being plotted.
633650
perspective : list or str
634651
``'[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]'``.

pygmt/tests/test_plot.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -191,32 +191,32 @@ def test_plot_colors_sizes_proj(data, region):
191191

192192

193193
@pytest.mark.mpl_image_compare
194-
def test_plot_matrix(data):
194+
def test_plot_matrix(data, region):
195195
"Plot the data passing in a matrix and specifying columns"
196196
fig = Figure()
197197
fig.plot(
198198
data=data,
199-
region=[10, 70, -5, 10],
199+
region=region,
200200
projection="M10i",
201201
style="cc",
202202
color="#aaaaaa",
203-
B="a",
203+
frame="a",
204204
columns="0,1,2+s0.005",
205205
)
206206
return fig
207207

208208

209209
@pytest.mark.mpl_image_compare
210-
def test_plot_matrix_color(data):
210+
def test_plot_matrix_color(data, region):
211211
"Plot the data passing in a matrix and using a colormap"
212212
fig = Figure()
213213
fig.plot(
214214
data=data,
215-
region=[10, 70, -5, 10],
215+
region=region,
216216
projection="X5i",
217217
style="c0.5c",
218218
cmap="rainbow",
219-
B="a",
219+
frame="a",
220220
)
221221
return fig
222222

pygmt/tests/test_plot3d.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_plot3d_matrix(data, region):
223223
projection="M10i",
224224
style="c1c",
225225
color="#aaaaaa",
226-
B=["a", "za"],
226+
frame=["a", "za"],
227227
columns="0,1,2",
228228
)
229229
return fig
@@ -242,7 +242,7 @@ def test_plot3d_matrix_color(data, region):
242242
style="c0.5c",
243243
cmap="rainbow",
244244
columns=[0, 1, 2, 2],
245-
B=["a", "za"],
245+
frame=["a", "za"],
246246
)
247247
return fig
248248

0 commit comments

Comments
 (0)