From cef2a2d5891d8c840bff0ab604a58690402a730d Mon Sep 17 00:00:00 2001 From: kmaterna Date: Sun, 21 Feb 2021 16:41:40 -0800 Subject: [PATCH 01/22] gallery figure for plot -Sv with vectors --- examples/gallery/plot/vectors.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/gallery/plot/vectors.py diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py new file mode 100644 index 00000000000..528558136a3 --- /dev/null +++ b/examples/gallery/plot/vectors.py @@ -0,0 +1,31 @@ +""" +Vectors +------ + +The :meth:`pygmt.Figure.plot` method can plot vectors without error ellipses. +The `style` parameter controls vector attributes as in GMT6 + +""" +import numpy as np +import pygmt + +# Generate a profile of points to plot +region = [-126, -65, 25, 52] +x = np.linspace(-100, -100, 12) # x vector coordinates +y = np.linspace(29, 47, 12) # y vector coordinates +xvec = np.linspace(1, 5, 12) # dx vector data +yvec = np.zeros(np.shape(y)) # dy vector data + +fig = pygmt.Figure() +# Create a 15x15 cm basemap with a Mercator projection (M) using the data region +fig.coast(region=region, projection="M15c", B="10.0", N='1', A='2000', W='0.5p,black') +# Plot vectors using: +# v0.2: vector size +# e: vector head at end +# a: 40 degree heads +# h0: head shape +# p: vector-head pen +# z: denotes vector's data in dx, dy (default is polar) +# direction: data arrays +fig.plot(x=x, y=y, style='v0.2+e+a40+gred+h0+p1p,red+z0.35', pen='1.0p,red', direction=[xvec, yvec]) +fig.show() From 72e17c0e2ae6843ff83a35db3d8afcd0feed5b17 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Mon, 22 Feb 2021 16:34:49 -0800 Subject: [PATCH 02/22] geo/cartesian/circ gallery example --- examples/gallery/plot/vectors.py | 70 +++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index 528558136a3..8b6bdd9f1c8 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -2,30 +2,60 @@ Vectors ------ -The :meth:`pygmt.Figure.plot` method can plot vectors without error ellipses. +The :meth:`pygmt.Figure.plot` method can plot cartesian, circular, and geographic vectors. The `style` parameter controls vector attributes as in GMT6 """ import numpy as np import pygmt -# Generate a profile of points to plot -region = [-126, -65, 25, 52] -x = np.linspace(-100, -100, 12) # x vector coordinates -y = np.linspace(29, 47, 12) # y vector coordinates -xvec = np.linspace(1, 5, 12) # dx vector data -yvec = np.zeros(np.shape(y)) # dy vector data - -fig = pygmt.Figure() -# Create a 15x15 cm basemap with a Mercator projection (M) using the data region -fig.coast(region=region, projection="M15c", B="10.0", N='1', A='2000', W='0.5p,black') -# Plot vectors using: -# v0.2: vector size -# e: vector head at end -# a: 40 degree heads -# h0: head shape -# p: vector-head pen -# z: denotes vector's data in dx, dy (default is polar) -# direction: data arrays -fig.plot(x=x, y=y, style='v0.2+e+a40+gred+h0+p1p,red+z0.35', pen='1.0p,red', direction=[xvec, yvec]) + +# Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US +region=[-127, -64, 24, 53] +fig=pygmt.Figure() +fig.coast(region=region, projection="M15c", B="10.0", N='1', A='4000', W='0.25p,black') + + +# plot math angle arcs with different radii +x=-110 +y=37 +startdir=90 +stopdir=180 +radius=1.8 +pen="1.5p,black" +arcstyles = np.repeat("m0.5c+ea", 7) +for arcstyle in arcstyles: + data = np.array([[x, y, radius, startdir, stopdir]]) + fig.plot(data=data, + style=arcstyle, + color="red3", + pen=pen) + stopdir+=40 + radius-=0.2 +fig.text(text="CIRCULAR", x=-112, y=44.2, font="13p,Helvetica-Bold,black", fill='white') + + +# plot cartesian vectors with different lengths +x=np.linspace(-100, -100, 12) # x vector coordinates +y=np.linspace(33,42.5, 12) # y vector coordinates +xvec = np.linspace(1, 5, 12) # dx vector data +yvec = np.zeros(np.shape(y)) # dy vector data +style = 'v0.2+e+a40+gred+h0+p1p,red+z0.35' +pen='1.0p,red' +fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) +fig.text(text="CARTESIAN", x=-95, y=44.2, font="13p,Helvetica-Bold,red", fill='white') + + +# plot geographic vectors using endpoints +NYC = [-74.0060, 40.7128] +CHI = [-87.6298, 41.8781] +SEA = [-122.3321, 47.6062] +NO = [-90.0715, 29.9511] +style = '=0.5+e+a30+gblue+h0.5+p1p,blue+s' # = for geographic coordinates, +s for coord end points +pen='1.0p,blue' +data = np.array([[NYC[0], NYC[1], CHI[0], CHI[1]]]); +data = np.vstack((data, np.array([[NYC[0], NYC[1], SEA[0], SEA[1]]]))); +data = np.vstack((data, np.array([[NYC[0], NYC[1], NO[0], NO[1]]]))); +fig.plot(data=data, style=style, pen=pen) +fig.text(text="GEOGRAPHIC", x=-74.5, y=44.2, font="13p,Helvetica-Bold,blue", fill='white') fig.show() From 2b8c4061141f99c0d2f9c56403b60b4cb2f01f57 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:38:29 +0000 Subject: [PATCH 03/22] [format-command] fixes --- examples/gallery/plot/vectors.py | 60 +++++++++++++++----------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index 8b6bdd9f1c8..9d6e7360364 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -9,53 +9,51 @@ import numpy as np import pygmt - # Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US -region=[-127, -64, 24, 53] -fig=pygmt.Figure() -fig.coast(region=region, projection="M15c", B="10.0", N='1', A='4000', W='0.25p,black') +region = [-127, -64, 24, 53] +fig = pygmt.Figure() +fig.coast(region=region, projection="M15c", B="10.0", N="1", A="4000", W="0.25p,black") # plot math angle arcs with different radii -x=-110 -y=37 -startdir=90 -stopdir=180 -radius=1.8 -pen="1.5p,black" +x = -110 +y = 37 +startdir = 90 +stopdir = 180 +radius = 1.8 +pen = "1.5p,black" arcstyles = np.repeat("m0.5c+ea", 7) for arcstyle in arcstyles: data = np.array([[x, y, radius, startdir, stopdir]]) - fig.plot(data=data, - style=arcstyle, - color="red3", - pen=pen) - stopdir+=40 - radius-=0.2 -fig.text(text="CIRCULAR", x=-112, y=44.2, font="13p,Helvetica-Bold,black", fill='white') + fig.plot(data=data, style=arcstyle, color="red3", pen=pen) + stopdir += 40 + radius -= 0.2 +fig.text(text="CIRCULAR", x=-112, y=44.2, font="13p,Helvetica-Bold,black", fill="white") # plot cartesian vectors with different lengths -x=np.linspace(-100, -100, 12) # x vector coordinates -y=np.linspace(33,42.5, 12) # y vector coordinates -xvec = np.linspace(1, 5, 12) # dx vector data -yvec = np.zeros(np.shape(y)) # dy vector data -style = 'v0.2+e+a40+gred+h0+p1p,red+z0.35' -pen='1.0p,red' +x = np.linspace(-100, -100, 12) # x vector coordinates +y = np.linspace(33, 42.5, 12) # y vector coordinates +xvec = np.linspace(1, 5, 12) # dx vector data +yvec = np.zeros(np.shape(y)) # dy vector data +style = "v0.2+e+a40+gred+h0+p1p,red+z0.35" +pen = "1.0p,red" fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) -fig.text(text="CARTESIAN", x=-95, y=44.2, font="13p,Helvetica-Bold,red", fill='white') +fig.text(text="CARTESIAN", x=-95, y=44.2, font="13p,Helvetica-Bold,red", fill="white") # plot geographic vectors using endpoints NYC = [-74.0060, 40.7128] CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] -NO = [-90.0715, 29.9511] -style = '=0.5+e+a30+gblue+h0.5+p1p,blue+s' # = for geographic coordinates, +s for coord end points -pen='1.0p,blue' -data = np.array([[NYC[0], NYC[1], CHI[0], CHI[1]]]); -data = np.vstack((data, np.array([[NYC[0], NYC[1], SEA[0], SEA[1]]]))); -data = np.vstack((data, np.array([[NYC[0], NYC[1], NO[0], NO[1]]]))); +NO = [-90.0715, 29.9511] +style = "=0.5+e+a30+gblue+h0.5+p1p,blue+s" # = for geographic coordinates, +s for coord end points +pen = "1.0p,blue" +data = np.array([[NYC[0], NYC[1], CHI[0], CHI[1]]]) +data = np.vstack((data, np.array([[NYC[0], NYC[1], SEA[0], SEA[1]]]))) +data = np.vstack((data, np.array([[NYC[0], NYC[1], NO[0], NO[1]]]))) fig.plot(data=data, style=style, pen=pen) -fig.text(text="GEOGRAPHIC", x=-74.5, y=44.2, font="13p,Helvetica-Bold,blue", fill='white') +fig.text( + text="GEOGRAPHIC", x=-74.5, y=44.2, font="13p,Helvetica-Bold,blue", fill="white" +) fig.show() From 2ede9ab25795a7b42ee8d8cfe7d7e4359ecb05d9 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Tue, 23 Feb 2021 08:57:37 -0800 Subject: [PATCH 04/22] editorial changes to vector example --- examples/gallery/plot/vectors.py | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index 9d6e7360364..37a70565a45 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -1,9 +1,9 @@ """ -Vectors +Cartesian, circular, and geographic vectors ------ -The :meth:`pygmt.Figure.plot` method can plot cartesian, circular, and geographic vectors. -The `style` parameter controls vector attributes as in GMT6 +The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and geographic vectors. +The ``style`` parameter controls vector attributes. """ import numpy as np @@ -12,34 +12,34 @@ # Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US region = [-127, -64, 24, 53] fig = pygmt.Figure() -fig.coast(region=region, projection="M15c", B="10.0", N="1", A="4000", W="0.25p,black") +fig.coast(region=region, projection="M15c", frame="10.0", borders="1", area_thresh="4000", shorelines="0.25p,black") + + +# plot cartesian vectors with different lengths +x = np.linspace(-115, -115, 12) # x vector coordinates +y = np.linspace(33.5, 42.5, 12) # y vector coordinates +xvec = np.linspace(1, 5, 12) # dx vector data +yvec = np.zeros(np.shape(y)) # dy vector data +style = "v0.2+e+a40+gred+h0+p1p,red+z0.35" +pen = "1.0p,red" +fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) +fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") # plot math angle arcs with different radii -x = -110 +x = -95 y = 37 -startdir = 90 -stopdir = 180 +startdir = 90 # in degrees +stopdir = 180 # in degrees radius = 1.8 pen = "1.5p,black" arcstyles = np.repeat("m0.5c+ea", 7) for arcstyle in arcstyles: data = np.array([[x, y, radius, startdir, stopdir]]) fig.plot(data=data, style=arcstyle, color="red3", pen=pen) - stopdir += 40 - radius -= 0.2 -fig.text(text="CIRCULAR", x=-112, y=44.2, font="13p,Helvetica-Bold,black", fill="white") - - -# plot cartesian vectors with different lengths -x = np.linspace(-100, -100, 12) # x vector coordinates -y = np.linspace(33, 42.5, 12) # y vector coordinates -xvec = np.linspace(1, 5, 12) # dx vector data -yvec = np.zeros(np.shape(y)) # dy vector data -style = "v0.2+e+a40+gred+h0+p1p,red+z0.35" -pen = "1.0p,red" -fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) -fig.text(text="CARTESIAN", x=-95, y=44.2, font="13p,Helvetica-Bold,red", fill="white") + stopdir += 40 # set the stop direction of the next circular vector + radius -= 0.2 # reduce radius of the next circular vector +fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") # plot geographic vectors using endpoints From 93a138e122314267441746e97fbee2df971fb1e1 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Tue, 23 Feb 2021 17:00:13 +0000 Subject: [PATCH 05/22] [format-command] fixes --- examples/gallery/plot/vectors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index 37a70565a45..db08402d5a6 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -12,7 +12,14 @@ # Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US region = [-127, -64, 24, 53] fig = pygmt.Figure() -fig.coast(region=region, projection="M15c", frame="10.0", borders="1", area_thresh="4000", shorelines="0.25p,black") +fig.coast( + region=region, + projection="M15c", + frame="10.0", + borders="1", + area_thresh="4000", + shorelines="0.25p,black", +) # plot cartesian vectors with different lengths From 2f1440ffceec1c1ab68317d18d1a0bffc8079982 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Wed, 24 Feb 2021 09:56:08 -0800 Subject: [PATCH 06/22] simplifying changes --- examples/gallery/plot/vectors.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index db08402d5a6..b2fee50933d 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -1,6 +1,6 @@ """ Cartesian, circular, and geographic vectors ------- +------------------------------------------- The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and geographic vectors. The ``style`` parameter controls vector attributes. @@ -9,27 +9,26 @@ import numpy as np import pygmt -# Create a plot with 15x15 cm basemap, Mercator projection (M) over the continental US -region = [-127, -64, 24, 53] +# create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() fig.coast( - region=region, + region=[-127, -64, 24, 53], projection="M15c", - frame="10.0", - borders="1", - area_thresh="4000", + frame=True, + borders=1, + area_thresh=4000, shorelines="0.25p,black", ) -# plot cartesian vectors with different lengths -x = np.linspace(-115, -115, 12) # x vector coordinates +# plot Cartesian vectors with different lengths +x = np.linspace(-116, -116, 12) # x vector coordinates y = np.linspace(33.5, 42.5, 12) # y vector coordinates -xvec = np.linspace(1, 5, 12) # dx vector data -yvec = np.zeros(np.shape(y)) # dy vector data -style = "v0.2+e+a40+gred+h0+p1p,red+z0.35" +direction = np.zeros(np.shape(y)) # direction of vector +length = np.linspace(0.5, 2.4, 12) # length vector data +style = "v0.2+e+a40+gred+h0+p1p,red" pen = "1.0p,red" -fig.plot(x=x, y=y, style=style, pen=pen, direction=[xvec, yvec]) +fig.plot(x=x, y=y, style=style, pen=pen, direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") From 0b905d7d9a6a331908283b9f352a41a41d7266b9 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Thu, 25 Feb 2021 15:00:44 -0800 Subject: [PATCH 07/22] np array construction for vector example --- examples/gallery/plot/vectors.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index b2fee50933d..c46a7cb3e59 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -21,14 +21,13 @@ ) -# plot Cartesian vectors with different lengths +# plot 12 Cartesian vectors with different lengths x = np.linspace(-116, -116, 12) # x vector coordinates y = np.linspace(33.5, 42.5, 12) # y vector coordinates -direction = np.zeros(np.shape(y)) # direction of vector -length = np.linspace(0.5, 2.4, 12) # length vector data -style = "v0.2+e+a40+gred+h0+p1p,red" -pen = "1.0p,red" -fig.plot(x=x, y=y, style=style, pen=pen, direction=[direction, length]) +direction = np.zeros(x.shape) # direction of vectors +length = np.linspace(0.5, 2.4, 12) # length of vectors +style = "v0.2+e+a40+gred+h0+p1p,red" # vectors with red pen and red fill, vector head at end, and 40 degree angle for vector head +fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") @@ -38,13 +37,14 @@ startdir = 90 # in degrees stopdir = 180 # in degrees radius = 1.8 -pen = "1.5p,black" -arcstyles = np.repeat("m0.5c+ea", 7) -for arcstyle in arcstyles: - data = np.array([[x, y, radius, startdir, stopdir]]) - fig.plot(data=data, style=arcstyle, color="red3", pen=pen) +arcstyle = "m0.5c+ea" +data = np.array([]).reshape((0, 5)); # empty array to hold circular vector data +for i in range(7): + single_vector = np.array([[x, y, radius, startdir, stopdir]]) + data = np.vstack((data, single_vector)); # append next vector to circular vector data stopdir += 40 # set the stop direction of the next circular vector - radius -= 0.2 # reduce radius of the next circular vector + radius -= 0.2 # reduce radius of the next circular vector +fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") @@ -54,11 +54,8 @@ SEA = [-122.3321, 47.6062] NO = [-90.0715, 29.9511] style = "=0.5+e+a30+gblue+h0.5+p1p,blue+s" # = for geographic coordinates, +s for coord end points -pen = "1.0p,blue" -data = np.array([[NYC[0], NYC[1], CHI[0], CHI[1]]]) -data = np.vstack((data, np.array([[NYC[0], NYC[1], SEA[0], SEA[1]]]))) -data = np.vstack((data, np.array([[NYC[0], NYC[1], NO[0], NO[1]]]))) -fig.plot(data=data, style=style, pen=pen) +data = np.array([NYC + CHI, NYC + SEA, NYC + NO]) +fig.plot(data=data, style=style, pen="1.0p,blue") fig.text( text="GEOGRAPHIC", x=-74.5, y=44.2, font="13p,Helvetica-Bold,blue", fill="white" ) From 9a5e866515a83edd40ae245fa258213ca71e032a Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Thu, 25 Feb 2021 23:03:58 +0000 Subject: [PATCH 08/22] [format-command] fixes --- examples/gallery/plot/vectors.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index c46a7cb3e59..968602757ae 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -38,13 +38,15 @@ stopdir = 180 # in degrees radius = 1.8 arcstyle = "m0.5c+ea" -data = np.array([]).reshape((0, 5)); # empty array to hold circular vector data +data = np.array([]).reshape((0, 5)) +# empty array to hold circular vector data for i in range(7): single_vector = np.array([[x, y, radius, startdir, stopdir]]) - data = np.vstack((data, single_vector)); # append next vector to circular vector data + data = np.vstack((data, single_vector)) + # append next vector to circular vector data stopdir += 40 # set the stop direction of the next circular vector - radius -= 0.2 # reduce radius of the next circular vector -fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") + radius -= 0.2 # reduce radius of the next circular vector +fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") From bb7ac0e29ea5f0095dc7cf5f72e7a10d07a92809 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Thu, 25 Feb 2021 19:20:10 -0800 Subject: [PATCH 09/22] Update examples/gallery/plot/vectors.py comments Co-authored-by: Dongdong Tian --- examples/gallery/plot/vectors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index 968602757ae..d2cf8df6cc2 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -26,7 +26,8 @@ y = np.linspace(33.5, 42.5, 12) # y vector coordinates direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors -style = "v0.2+e+a40+gred+h0+p1p,red" # vectors with red pen and red fill, vector head at end, and 40 degree angle for vector head +# vectors with red pen and fill, vector head at end, and 40 degree angle for vector head +style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") From c6c5e71c3094e718d6929abac2822d81fdaf6e95 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Thu, 25 Feb 2021 19:20:55 -0800 Subject: [PATCH 10/22] Update examples/gallery/plot/vectors.py remove for loop Co-authored-by: Dongdong Tian --- examples/gallery/plot/vectors.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index d2cf8df6cc2..e26eecc9b4c 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -32,21 +32,17 @@ fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") -# plot math angle arcs with different radii -x = -95 -y = 37 -startdir = 90 # in degrees -stopdir = 180 # in degrees -radius = 1.8 -arcstyle = "m0.5c+ea" -data = np.array([]).reshape((0, 5)) -# empty array to hold circular vector data -for i in range(7): - single_vector = np.array([[x, y, radius, startdir, stopdir]]) - data = np.vstack((data, single_vector)) - # append next vector to circular vector data - stopdir += 40 # set the stop direction of the next circular vector - radius -= 0.2 # reduce radius of the next circular vector +# plot 7 math angle arcs with different radii +num = 7 +x = np.full(num, -95) # x coordinates of the center +y = np.full(num, 37) # y coordinates of the center +radius = 1.8 - 0.2 * np.arange(0, num) # radius +startdir = np.full(num, 90) # start direction in degrees +stopdir = 180 + 40 * np.arange(0, num) # stop direction in degrees +arcstyle = "m0.5c+ea" # vector with an arrow at end + +# data for circular vectors +data = np.column_stack([x, y, radius, startdir, stopdir]) fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") From d4d8e8476e92e1db7a1936fd5c3174112f2b62e7 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Thu, 25 Feb 2021 19:24:28 -0800 Subject: [PATCH 11/22] Update examples/gallery/plot/vectors.py Co-authored-by: Dongdong Tian --- examples/gallery/plot/vectors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/plot/vectors.py index e26eecc9b4c..0d9d5cb2f7a 100644 --- a/examples/gallery/plot/vectors.py +++ b/examples/gallery/plot/vectors.py @@ -52,7 +52,9 @@ CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] NO = [-90.0715, 29.9511] -style = "=0.5+e+a30+gblue+h0.5+p1p,blue+s" # = for geographic coordinates, +s for coord end points +# `=` means geographic vectors. +# With the modifier '+s', the input data should contain coordinates of start and end points +style = "=0.5c+s+e+a30+gblue+h0.5+p1p,blue" data = np.array([NYC + CHI, NYC + SEA, NYC + NO]) fig.plot(data=data, style=style, pen="1.0p,blue") fig.text( From 1b092889951c8daf99453293525a85e6b3c7f37e Mon Sep 17 00:00:00 2001 From: kmaterna Date: Thu, 25 Feb 2021 19:38:55 -0800 Subject: [PATCH 12/22] moving vectors to line gallery --- examples/gallery/{plot => line}/vectors.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gallery/{plot => line}/vectors.py (100%) diff --git a/examples/gallery/plot/vectors.py b/examples/gallery/line/vectors.py similarity index 100% rename from examples/gallery/plot/vectors.py rename to examples/gallery/line/vectors.py From 3115efa618b5790b5b3b8d3665505bc1358e98a1 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Fri, 26 Feb 2021 04:47:15 +0000 Subject: [PATCH 13/22] [format-command] fixes --- examples/gallery/line/vectors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 0d9d5cb2f7a..94cb0880401 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -27,7 +27,7 @@ direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors # vectors with red pen and fill, vector head at end, and 40 degree angle for vector head -style = "v0.2c+e+a40+gred+h0+p1p,red" +style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") @@ -35,8 +35,8 @@ # plot 7 math angle arcs with different radii num = 7 x = np.full(num, -95) # x coordinates of the center -y = np.full(num, 37) # y coordinates of the center -radius = 1.8 - 0.2 * np.arange(0, num) # radius +y = np.full(num, 37) # y coordinates of the center +radius = 1.8 - 0.2 * np.arange(0, num) # radius startdir = np.full(num, 90) # start direction in degrees stopdir = 180 + 40 * np.arange(0, num) # stop direction in degrees arcstyle = "m0.5c+ea" # vector with an arrow at end @@ -52,9 +52,9 @@ CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] NO = [-90.0715, 29.9511] -# `=` means geographic vectors. +# `=` means geographic vectors. # With the modifier '+s', the input data should contain coordinates of start and end points -style = "=0.5c+s+e+a30+gblue+h0.5+p1p,blue" +style = "=0.5c+s+e+a30+gblue+h0.5+p1p,blue" data = np.array([NYC + CHI, NYC + SEA, NYC + NO]) fig.plot(data=data, style=style, pen="1.0p,blue") fig.text( From 0b22dee42e5ae6b9e8bb0882ce00f2cc2a141668 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Fri, 26 Feb 2021 12:24:40 -0800 Subject: [PATCH 14/22] Update examples/gallery/line/vectors.py line reorder Co-authored-by: Dongdong Tian --- examples/gallery/line/vectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 94cb0880401..d2f4704db18 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -39,10 +39,10 @@ radius = 1.8 - 0.2 * np.arange(0, num) # radius startdir = np.full(num, 90) # start direction in degrees stopdir = 180 + 40 * np.arange(0, num) # stop direction in degrees -arcstyle = "m0.5c+ea" # vector with an arrow at end - # data for circular vectors data = np.column_stack([x, y, radius, startdir, stopdir]) + +arcstyle = "m0.5c+ea" # Circular vector (m) with an arrow at end fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") From 6a2220084fedafc2ef8737c8f2224b8f754ba4f6 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Fri, 26 Feb 2021 12:24:53 -0800 Subject: [PATCH 15/22] Update examples/gallery/line/vectors.py comment added Co-authored-by: Dongdong Tian --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index d2f4704db18..58b31ec43ed 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -26,7 +26,7 @@ y = np.linspace(33.5, 42.5, 12) # y vector coordinates direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors -# vectors with red pen and fill, vector head at end, and 40 degree angle for vector head +# Cartesian vectors (v) with red pen and fill, vector head at end, and 40 degree angle for vector head style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") From 7fc33a29ec1c4aafb67210a098fd3e451dd2c8b1 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Sat, 27 Feb 2021 21:05:07 -0800 Subject: [PATCH 16/22] Update examples/gallery/line/vectors.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 58b31ec43ed..23be6ffe7f0 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -47,7 +47,7 @@ fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") -# plot geographic vectors using endpoints +# Right: plot geographic vectors using endpoints NYC = [-74.0060, 40.7128] CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] From 70698d2fe5a2cf220121c2a54e02a44dc23bd142 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Sat, 27 Feb 2021 21:05:17 -0800 Subject: [PATCH 17/22] Update examples/gallery/line/vectors.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 23be6ffe7f0..cb4889a0f01 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -32,7 +32,7 @@ fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") -# plot 7 math angle arcs with different radii +# Middle: plot 7 math angle arcs with different radii num = 7 x = np.full(num, -95) # x coordinates of the center y = np.full(num, 37) # y coordinates of the center From ab484e05e3512b43dd20da0c1b4fd70b6ff95554 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Sat, 27 Feb 2021 21:05:24 -0800 Subject: [PATCH 18/22] Update examples/gallery/line/vectors.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index cb4889a0f01..4866622e4c4 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -21,7 +21,7 @@ ) -# plot 12 Cartesian vectors with different lengths +# Left: plot 12 Cartesian vectors with different lengths x = np.linspace(-116, -116, 12) # x vector coordinates y = np.linspace(33.5, 42.5, 12) # y vector coordinates direction = np.zeros(x.shape) # direction of vectors From 5bdb296e839406752500e4ae7bb43cc932bf408a Mon Sep 17 00:00:00 2001 From: kmaterna Date: Mon, 1 Mar 2021 09:16:25 -0800 Subject: [PATCH 19/22] documentation improvements for vector heads --- examples/gallery/line/vectors.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 4866622e4c4..765b5f251f4 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -4,6 +4,7 @@ The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and geographic vectors. The ``style`` parameter controls vector attributes. +Vector documentation: https://www.pygmt.org/dev/gallery/line/vector-heads-tails.html """ import numpy as np @@ -26,7 +27,8 @@ y = np.linspace(33.5, 42.5, 12) # y vector coordinates direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors -# Cartesian vectors (v) with red pen and fill, vector head at end, and 40 degree angle for vector head +# Cartesian vectors (v) with red pen and fill (+g, +p), vector head at end (+e), +# and 40 degree angle with no indentation for vector head (+a, +h) style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") @@ -41,7 +43,6 @@ stopdir = 180 + 40 * np.arange(0, num) # stop direction in degrees # data for circular vectors data = np.column_stack([x, y, radius, startdir, stopdir]) - arcstyle = "m0.5c+ea" # Circular vector (m) with an arrow at end fig.plot(data=data, style=arcstyle, color="red3", pen="1.5p,black") fig.text(text="CIRCULAR", x=-95, y=44.2, font="13p,Helvetica-Bold,black", fill="white") From 1efe495ef69c44390d97ccca9ccb27bd60098419 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 1 Mar 2021 17:18:33 +0000 Subject: [PATCH 20/22] [format-command] fixes --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index 765b5f251f4..f0731e7b398 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -27,7 +27,7 @@ y = np.linspace(33.5, 42.5, 12) # y vector coordinates direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors -# Cartesian vectors (v) with red pen and fill (+g, +p), vector head at end (+e), +# Cartesian vectors (v) with red pen and fill (+g, +p), vector head at end (+e), # and 40 degree angle with no indentation for vector head (+a, +h) style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) From 220f4f9e8161fa549f2dbfe0f3c8d2cf70ecabe4 Mon Sep 17 00:00:00 2001 From: kmaterna Date: Tue, 2 Mar 2021 09:45:53 -0800 Subject: [PATCH 21/22] Update examples/gallery/line/vectors.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/line/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index f0731e7b398..c0324d5abbd 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -28,7 +28,7 @@ direction = np.zeros(x.shape) # direction of vectors length = np.linspace(0.5, 2.4, 12) # length of vectors # Cartesian vectors (v) with red pen and fill (+g, +p), vector head at end (+e), -# and 40 degree angle with no indentation for vector head (+a, +h) +# and 40 degree angle (+a) with no indentation for vector head (+h) style = "v0.2c+e+a40+gred+h0+p1p,red" fig.plot(x=x, y=y, style=style, pen="1p,red", direction=[direction, length]) fig.text(text="CARTESIAN", x=-112, y=44.2, font="13p,Helvetica-Bold,red", fill="white") From a5311a5484dc186867ee382392ed231c0cd8bc7e Mon Sep 17 00:00:00 2001 From: kmaterna Date: Tue, 2 Mar 2021 09:46:27 -0800 Subject: [PATCH 22/22] Update vectors.py doc linking functions Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/line/vectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/line/vectors.py b/examples/gallery/line/vectors.py index c0324d5abbd..480cd9cb89b 100644 --- a/examples/gallery/line/vectors.py +++ b/examples/gallery/line/vectors.py @@ -3,8 +3,8 @@ ------------------------------------------- The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and geographic vectors. -The ``style`` parameter controls vector attributes. -Vector documentation: https://www.pygmt.org/dev/gallery/line/vector-heads-tails.html +The ``style`` parameter controls vector attributes. See also +:doc:`Vector attributes documentation `. """ import numpy as np