From 5941e3360bc15224946099f8f71b3bb9feda7cbf Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 13 Mar 2021 17:49:08 -0500 Subject: [PATCH 01/75] create vectors file from lines, add example --- examples/tutorials/vectors.py | 146 ++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 examples/tutorials/vectors.py diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py new file mode 100644 index 00000000000..5b2c083ae3a --- /dev/null +++ b/examples/tutorials/vectors.py @@ -0,0 +1,146 @@ +""" +Plot Vectors +========== + +Plotting vectors is handled by :meth:`pygmt.Figure.plot`. + +.. note:: + + This tutorial assumes the use of a Python notebook, such as IPython or Jupyter Notebook. + To see the figures while using a Python script instead, use + ``fig.show(method="external")`` to display the figure in the default PDF viewer. + + To save the figure, use ``fig.savefig("figname.pdf")`` where ``"figname.pdf"`` + is the desired name and file extension for the saved figure. +""" +# TODO: change this number to reflect the correct thumbnail +# sphinx_gallery_thumbnail_number = 3 + +import numpy as np +import pygmt +""" +# Plot Vectors +---------- + +Create a Cartesian figure using ``projection`` parameter and set the axis scales +using ``region`` (in this case, each axis is 0-25). Pass a `numpy` array object that contains lists of all the vectors to be plotted. +""" +# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +vector_1 = [2, 3, 45, 4] +vector_2 = [7.5, 8.3, -120.5, 7.2] +# Create a list of lists that include each vector information +data = np.array([vector_1] + [vector_2]) + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X10c/10c", + frame="a", + data=data, + style="v0.6c+e", + pen="2p", + color="red3" +) +fig.show() + +######################################################################################## +# Additional line segments can be added by including additional values for ``x`` +# and ``y``. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 6, 9], + y=[5, 7, 4], + pen="1p,black", +) +fig.show() + +######################################################################################## +# To plot multiple lines, :meth:`pygmt.Figure.plot` needs to be used for each +# additional line. Arguments such as ``region``, ``projection``, and ``frame`` do +# not need to be repeated in subsequent uses. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 6, 9], + y=[5, 7, 4], + pen="2p,blue", +) +fig.plot(x=[2, 4, 10], y=[3, 8, 9], pen="2p,red") +fig.show() + +######################################################################################## +# Change line attributes +# ---------------------- +# +# The line attributes can be set by the ``pen`` parameter. ``pen`` takes a string +# argument with the optional values *width*,\ *color*,\ *style*. +# +# In the example below, the pen width is set to ``5p``, and with ``black`` as the +# default color and ``solid`` as the default style. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 8], + y=[3, 9], + pen="5p", +) +fig.show() + +######################################################################################## +# The line color can be set and is added after the line width to the ``pen`` parameter. +# In the example below, the line color is set to ``red``. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 8], + y=[3, 9], + pen="5p,red", +) +fig.show() + +######################################################################################## +# The line style can be set and is added after the line width or color to the +# ``pen`` parameter. In the example below, the line style is set to +# ``..-`` (*dot dot dash*), and the default color ``black`` is used. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 8], + y=[3, 9], + pen="5p,..-", +) +fig.show() + +######################################################################################## +# The line width, color, and style can all be set in the same ``pen`` parameter. In the +# example below, the line width is set to ``7p``, the color is set to ``green``, and the +# line style is ``-.-`` (*dash dot dash*). +# +# For a gallery showing other ``pen`` settings, see :doc:`/gallery/lines/linestyles`. + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X25c/20c", + frame="a", + x=[1, 8], + y=[3, 9], + pen="7p,green,-.-", +) +fig.show() From ff9e0f8fd19adbb22612e925269ad09b9a486203 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 13 Mar 2021 17:51:00 -0500 Subject: [PATCH 02/75] Fix code snippet syntax --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 5b2c083ae3a..1c0db842cc3 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -23,7 +23,7 @@ ---------- Create a Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-25). Pass a `numpy` array object that contains lists of all the vectors to be plotted. +using ``region`` (in this case, each axis is 0-25). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. """ # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] From 65e86075bc8ff7086080374532bb669d651c9843 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Sat, 13 Mar 2021 18:00:58 -0500 Subject: [PATCH 03/75] Update index.rst to include vectors.py in Guide --- doc/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/index.rst b/doc/index.rst index 0bb9b4d24f5..3c486dd2781 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -34,6 +34,7 @@ tutorials/regions.rst tutorials/plot.rst tutorials/lines.rst + tutorials/vectors.rst tutorials/text.rst tutorials/contour_map.rst tutorials/earth_relief.rst From 69b9296c6a9948e8c6b688ca938f5c1c0d961d87 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 17 Mar 2021 14:40:09 -0400 Subject: [PATCH 04/75] Added circular vector example to vectors.py --- examples/tutorials/vectors.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 1c0db842cc3..76b2f362ecd 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -43,6 +43,45 @@ ) fig.show() +######################################################################################## +# Circular vectors can be plotted using an ``x`` and ``y`` value to specify +# where the origin of the arc will be located on the plane. The variable +# ``diam`` is used to specify the diameter of the arc while the ``startDeg`` and +# ``stopDeg`` specify at what angle the arc will originate and end respectively. + +fig = pygmt.Figure() + +reg_x_lowbound = 0 +reg_x_upperbound = 8 +reg_y_lowbound = -15 +reg_y_upperbound = 15 + +fig.basemap( + region=[ + reg_x_lowbound, + reg_x_upperbound, + reg_y_lowbound, + reg_y_upperbound + ], + projection="X15c/10c", + frame=True, +) + +x = 4 +y = 0 +diam = 4 +startDeg = 90 +stopDeg = 270 + +data = np.array([[x, y, diam, startDeg, stopDeg]]) +fig.plot( + data=data, + style="m0.5c+ea", + color="red3", + pen="1.5p,black" +) +fig.show() + ######################################################################################## # Additional line segments can be added by including additional values for ``x`` # and ``y``. From b3334294c92e96665ce3d08623e2e2f48e823a48 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 17 Mar 2021 15:43:32 -0400 Subject: [PATCH 05/75] re-formatted vectors.py using makefile --- examples/tutorials/vectors.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 76b2f362ecd..eba2e356732 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -18,6 +18,7 @@ import numpy as np import pygmt + """ # Plot Vectors ---------- @@ -39,7 +40,7 @@ data=data, style="v0.6c+e", pen="2p", - color="red3" + color="red3", ) fig.show() @@ -57,12 +58,7 @@ reg_y_upperbound = 15 fig.basemap( - region=[ - reg_x_lowbound, - reg_x_upperbound, - reg_y_lowbound, - reg_y_upperbound - ], + region=[reg_x_lowbound, reg_x_upperbound, reg_y_lowbound, reg_y_upperbound], projection="X15c/10c", frame=True, ) @@ -74,12 +70,7 @@ stopDeg = 270 data = np.array([[x, y, diam, startDeg, stopDeg]]) -fig.plot( - data=data, - style="m0.5c+ea", - color="red3", - pen="1.5p,black" -) +fig.plot(data=data, style="m0.5c+ea", color="red3", pen="1.5p,black") fig.show() ######################################################################################## From 4593cd30d60e9860633143d4586688ade72783b7 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Fri, 19 Mar 2021 13:41:01 -0400 Subject: [PATCH 06/75] Changed verbage in vectors.py for ploting circular vectors --- examples/tutorials/vectors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index eba2e356732..3cd9c09904f 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -46,9 +46,9 @@ ######################################################################################## # Circular vectors can be plotted using an ``x`` and ``y`` value to specify -# where the origin of the arc will be located on the plane. The variable -# ``diam`` is used to specify the diameter of the arc while the ``startDeg`` and -# ``stopDeg`` specify at what angle the arc will originate and end respectively. +# where the origin of the circle will be located on the plane. The variable +# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and +# ``stopDeg`` specify at what angle the arc will begin and end respectively. fig = pygmt.Figure() From e54db50631d54c8665b28abd2515abfb7938e811 Mon Sep 17 00:00:00 2001 From: Claire Klima Date: Fri, 19 Mar 2021 14:02:59 -0400 Subject: [PATCH 07/75] Attempt to fix formatting. --- examples/tutorials/vectors.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 3cd9c09904f..2573b923895 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -1,5 +1,5 @@ """ -Plot Vectors +Plot vectors ========== Plotting vectors is handled by :meth:`pygmt.Figure.plot`. @@ -19,17 +19,18 @@ import numpy as np import pygmt -""" -# Plot Vectors ----------- +####################################################################################### +# Plot vectors +# ---------- +# +# Create a Cartesian figure using ``projection`` parameter and set the axis scales +# using ``region`` (in this case, each axis is 0-25). Pass a ``numpy`` array object +# that contains lists of all vectors to be plotted. -Create a Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-25). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. -""" -# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +# Vector specifications are structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] -# Create a list of lists that include each vector information +# Create a list of lists that include each vector information. data = np.array([vector_1] + [vector_2]) fig = pygmt.Figure() @@ -47,8 +48,8 @@ ######################################################################################## # Circular vectors can be plotted using an ``x`` and ``y`` value to specify # where the origin of the circle will be located on the plane. The variable -# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and -# ``stopDeg`` specify at what angle the arc will begin and end respectively. +# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` +# and ``stopDeg`` specify at what angle the arc will begin and end respectively. fig = pygmt.Figure() From adb3b662303daa81ce592f6be2bbbe58a863d640 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Fri, 19 Mar 2021 14:04:43 -0400 Subject: [PATCH 08/75] Edited vector specification to accomadate code style --- examples/tutorials/vectors.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 3cd9c09904f..8843f8b7ca4 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -50,27 +50,19 @@ # ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and # ``stopDeg`` specify at what angle the arc will begin and end respectively. -fig = pygmt.Figure() - -reg_x_lowbound = 0 -reg_x_upperbound = 8 -reg_y_lowbound = -15 -reg_y_upperbound = 15 +# vector specifications structured as: [x_start, y_start, diameter, degree_start, degree_stop] +data = np.array([[5, 5, 2.5, 90, 270]]) -fig.basemap( - region=[reg_x_lowbound, reg_x_upperbound, reg_y_lowbound, reg_y_upperbound], - projection="X15c/10c", - frame=True, +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X10c/10c", + frame="a", + data=data, + style="m0.5c+ea", + pen="2p", + color="red3", ) - -x = 4 -y = 0 -diam = 4 -startDeg = 90 -stopDeg = 270 - -data = np.array([[x, y, diam, startDeg, stopDeg]]) -fig.plot(data=data, style="m0.5c+ea", color="red3", pen="1.5p,black") fig.show() ######################################################################################## From 5d2c272601ab77bf8e04f475fadcbbad3d7db015 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 19 Mar 2021 15:02:52 -0400 Subject: [PATCH 09/75] Duplicate examples. Change format --- examples/tutorials/vectors.py | 66 +++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 3cd9c09904f..be89196e355 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -20,12 +20,37 @@ import pygmt """ -# Plot Vectors +## Plot Caretesian Vectors ---------- +Create a simple Cartesian figure using ``projection`` parameter and set the axis scales +using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. + +Notice that the ``v`` in the ``style`` parameter stands for vector. It distinguishes it from regular lines. Additionally, the data points are passed using the parameter `data` which is a ``numpy`` array object. + +While this looks identical to a line, it has additional attributes that we'll discuss throughout this tutorial. +""" + +# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +vector_1 = [2, 3, 45, 4] +# Create a list of lists that include each vector information +data = np.array([vector_1]) + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X10c/10c", + frame="a", + data=data, + style="v0c", +) +fig.show() + +""" Create a Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-25). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. +using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. """ + # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] @@ -44,12 +69,39 @@ ) fig.show() -######################################################################################## -# Circular vectors can be plotted using an ``x`` and ``y`` value to specify -# where the origin of the circle will be located on the plane. The variable -# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and -# ``stopDeg`` specify at what angle the arc will begin and end respectively. +""" +Create a Cartesian figure using ``projection`` parameter and set the axis scales +using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. +""" + +# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +vector_1 = [2, 3, 45, 4] +vector_2 = [7.5, 8.3, -120.5, 7.2] +# Create a list of lists that include each vector information +data = np.array([vector_1] + [vector_2]) + +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X10c/10c", + frame="a", + data=data, + style="v0.6c+e", + pen="2p", + color="red3", +) +fig.show() + +''' +## Plot Circular Vectors +---------- + +Circular vectors can be plotted using an ``x`` and ``y`` value to specify +where the origin of the circle will be located on the plane. The variable +``diam`` is used to specify the diameter of the circle while the ``startDeg`` and +``stopDeg`` specify at what angle the arc will begin and end respectively. +''' fig = pygmt.Figure() reg_x_lowbound = 0 From d3d489ac3dd12b8b0c7af068152fee2f0fc8ed8c Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 19 Mar 2021 15:54:08 -0400 Subject: [PATCH 10/75] add four total examples --- examples/tutorials/vectors.py | 88 ++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index be89196e355..2adbade19f6 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -19,50 +19,82 @@ import numpy as np import pygmt -""" +''' ## Plot Caretesian Vectors ---------- -Create a simple Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. +Create a simple Cartesian vector using a starting point through +``x``, ``y``, and ``direction`` parameters. The direction is specified +by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` -Notice that the ``v`` in the ``style`` parameter stands for vector. It distinguishes it from regular lines. Additionally, the data points are passed using the parameter `data` which is a ``numpy`` array object. +On the shown figure, the plot is projected on a _10X10_ region, +which is specified by the `region` and `projection` parameters. -While this looks identical to a line, it has additional attributes that we'll discuss throughout this tutorial. -""" +Notice that the ``v`` in the ``style`` parameter stands for +vector; it distinguishes it from regular lines and allows for +different customization. +''' -# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] -vector_1 = [2, 3, 45, 4] -# Create a list of lists that include each vector information -data = np.array([vector_1]) +fig = pygmt.Figure() +fig.plot( + region=[0, 10, 0, 10], + projection="X10c/10c", + frame="a", + x = 2, + y = 8, + direction = [[-45],[6]], + style="v0c" +) +fig.show() + +''' +In this example, we apply the same concept shown previously to plot multiple +vectors. Notice that instead of passing int/float to ``x`` and ``y``, a list +of all x and y coordinates will be passed. Similarly, the length of direction +list will increase accordingly. + +Additionally, we changed the style of the vector to include a red +arrowhead and increased the thickness of the line. A list of different +styling attributes can be found in +[Vector attributes documentation](https://www.pygmt.org/latest/gallery/lines/vector_heads_tails.html) +''' fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", frame="a", - data=data, - style="v0c", + x = [2,4], + y = [8,1], + direction = [[-45,23],[6,3]], + style="v0.6c+e", + pen="2p", + color="red3", ) fig.show() -""" -Create a Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. -""" +''' +Vectors can also be plotted by including all the information +about a vector ina single list. However, this requires creating +a list for all vectors and passing it into a ``numpy`` array object. +Each vector list contains the information structured as: +``[x_start, y_start, direction_degrees, magnitude]`` + +If this approach is chosen, ``data`` parameter must be +used instead of ``x``, ``y`` and ``direction``. +''' -# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] -vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information -data = np.array([vector_1] + [vector_2]) +vectors = np.array([vector_1]) +# vectors structure: [[ 2 3 45 4]] fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", frame="a", - data=data, + data=vectors, style="v0.6c+e", pen="2p", color="red3", @@ -70,23 +102,25 @@ fig.show() -""" -Create a Cartesian figure using ``projection`` parameter and set the axis scales -using ``region`` (in this case, each axis is 0-10). Pass a ``numpy`` array object that contains lists of all the vectors to be plotted. -""" +''' +Using the functionality mentioned in the previous example, +multiple vectors can be plotted at the same time. Another +vector could be simply added to the 2d ``numpy`` array object +and passed using `data` parameter. +''' # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information -data = np.array([vector_1] + [vector_2]) - +vectors = np.array([vector_1] + [vector_2]) +# data looks like fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", frame="a", - data=data, + data=vectors, style="v0.6c+e", pen="2p", color="red3", From fb4c82b63f0b543133bee655c82be922e1f20783 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 20 Mar 2021 15:08:31 -0400 Subject: [PATCH 11/75] change formatting to use # symbol instead of """ --- examples/tutorials/vectors.py | 94 +++++++++++++++++------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 2adbade19f6..109531c80f3 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -19,21 +19,20 @@ import numpy as np import pygmt -''' -## Plot Caretesian Vectors ----------- - -Create a simple Cartesian vector using a starting point through -``x``, ``y``, and ``direction`` parameters. The direction is specified -by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` - -On the shown figure, the plot is projected on a _10X10_ region, -which is specified by the `region` and `projection` parameters. - -Notice that the ``v`` in the ``style`` parameter stands for -vector; it distinguishes it from regular lines and allows for -different customization. -''' +######################################################################################## +# Plot Caretesian Vectors +# ---------- +# +# Create a simple Cartesian vector using a starting point through +# ``x``, ``y``, and ``direction`` parameters. The direction is specified +# by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` +# +# On the shown figure, the plot is projected on a _10X10_ region, +# which is specified by the `region` and `projection` parameters. +# +# Notice that the ``v`` in the ``style`` parameter stands for +# vector; it distinguishes it from regular lines and allows for +# different customization. fig = pygmt.Figure() fig.plot( @@ -47,17 +46,17 @@ ) fig.show() -''' -In this example, we apply the same concept shown previously to plot multiple -vectors. Notice that instead of passing int/float to ``x`` and ``y``, a list -of all x and y coordinates will be passed. Similarly, the length of direction -list will increase accordingly. +######################################################################################## +# In this example, we apply the same concept shown previously to plot multiple +# vectors. Notice that instead of passing int/float to ``x`` and ``y``, a list +# of all x and y coordinates will be passed. Similarly, the length of direction +# list will increase accordingly. +# +# Additionally, we changed the style of the vector to include a red +# arrowhead and increased the thickness of the line. A list of different +# styling attributes can be found in +# [Vector attributes documentation](https://www.pygmt.org/latest/gallery/lines/vector_heads_tails.html) -Additionally, we changed the style of the vector to include a red -arrowhead and increased the thickness of the line. A list of different -styling attributes can be found in -[Vector attributes documentation](https://www.pygmt.org/latest/gallery/lines/vector_heads_tails.html) -''' fig = pygmt.Figure() fig.plot( @@ -73,16 +72,16 @@ ) fig.show() -''' -Vectors can also be plotted by including all the information -about a vector ina single list. However, this requires creating -a list for all vectors and passing it into a ``numpy`` array object. -Each vector list contains the information structured as: -``[x_start, y_start, direction_degrees, magnitude]`` +######################################################################################## +# Vectors can also be plotted by including all the information +# about a vector ina single list. However, this requires creating +# a list for all vectors and passing it into a ``numpy`` array object. +# Each vector list contains the information structured as: +# ``[x_start, y_start, direction_degrees, magnitude]`` +# +# If this approach is chosen, ``data`` parameter must be +# used instead of ``x``, ``y`` and ``direction``. -If this approach is chosen, ``data`` parameter must be -used instead of ``x``, ``y`` and ``direction``. -''' vector_1 = [2, 3, 45, 4] # Create a list of lists that include each vector information @@ -102,12 +101,12 @@ fig.show() -''' -Using the functionality mentioned in the previous example, -multiple vectors can be plotted at the same time. Another -vector could be simply added to the 2d ``numpy`` array object -and passed using `data` parameter. -''' +######################################################################################## +# Using the functionality mentioned in the previous example, +# multiple vectors can be plotted at the same time. Another +# vector could be simply added to the 2d ``numpy`` array object +# and passed using `data` parameter. + # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] @@ -127,15 +126,15 @@ ) fig.show() -''' +######################################################################################## ## Plot Circular Vectors ----------- +# ---------- +# +# Circular vectors can be plotted using an ``x`` and ``y`` value to specify +# where the origin of the circle will be located on the plane. The variable +# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and +# ``stopDeg`` specify at what angle the arc will begin and end respectively. -Circular vectors can be plotted using an ``x`` and ``y`` value to specify -where the origin of the circle will be located on the plane. The variable -``diam`` is used to specify the diameter of the circle while the ``startDeg`` and -``stopDeg`` specify at what angle the arc will begin and end respectively. -''' fig = pygmt.Figure() reg_x_lowbound = 0 @@ -160,6 +159,7 @@ fig.show() ######################################################################################## +# FIXME: Everything after this is from ``lines.py`` and must be removed # Additional line segments can be added by including additional values for ``x`` # and ``y``. From 9d87fb71fbad541cc7eb6e23e5b77c81ffef3d23 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 20 Mar 2021 15:14:17 -0400 Subject: [PATCH 12/75] change more formatting --- examples/tutorials/vectors.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 109531c80f3..9289b63c3e1 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -22,14 +22,14 @@ ######################################################################################## # Plot Caretesian Vectors # ---------- -# +# # Create a simple Cartesian vector using a starting point through # ``x``, ``y``, and ``direction`` parameters. The direction is specified # by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` -# +# # On the shown figure, the plot is projected on a _10X10_ region, # which is specified by the `region` and `projection` parameters. -# +# # Notice that the ``v`` in the ``style`` parameter stands for # vector; it distinguishes it from regular lines and allows for # different customization. @@ -51,13 +51,12 @@ # vectors. Notice that instead of passing int/float to ``x`` and ``y``, a list # of all x and y coordinates will be passed. Similarly, the length of direction # list will increase accordingly. -# +# # Additionally, we changed the style of the vector to include a red # arrowhead and increased the thickness of the line. A list of different # styling attributes can be found in # [Vector attributes documentation](https://www.pygmt.org/latest/gallery/lines/vector_heads_tails.html) - fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], @@ -78,11 +77,10 @@ # a list for all vectors and passing it into a ``numpy`` array object. # Each vector list contains the information structured as: # ``[x_start, y_start, direction_degrees, magnitude]`` -# +# # If this approach is chosen, ``data`` parameter must be # used instead of ``x``, ``y`` and ``direction``. - vector_1 = [2, 3, 45, 4] # Create a list of lists that include each vector information vectors = np.array([vector_1]) @@ -100,20 +98,22 @@ ) fig.show() - ######################################################################################## # Using the functionality mentioned in the previous example, # multiple vectors can be plotted at the same time. Another # vector could be simply added to the 2d ``numpy`` array object # and passed using `data` parameter. - # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information vectors = np.array([vector_1] + [vector_2]) -# data looks like +print(vectors) +# vectors structure: +# [[ 2. 3. 45. 4. ] +# [ 7.5 8.3 -120.5 7.2]] + fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], @@ -127,9 +127,9 @@ fig.show() ######################################################################################## -## Plot Circular Vectors +# # Plot Circular Vectors # ---------- -# +# # Circular vectors can be plotted using an ``x`` and ``y`` value to specify # where the origin of the circle will be located on the plane. The variable # ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and From c1dee1de2830be6fe6b4a8cc5a436025c2d7d6b4 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 20 Mar 2021 15:22:03 -0400 Subject: [PATCH 13/75] fromat using black --- examples/tutorials/vectors.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 5287aca62fb..a835993b86c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -39,10 +39,10 @@ region=[0, 10, 0, 10], projection="X10c/10c", frame="a", - x = 2, - y = 8, - direction = [[-45],[6]], - style="v0c" + x=2, + y=8, + direction=[[-45], [6]], + style="v0c", ) fig.show() @@ -62,9 +62,9 @@ region=[0, 10, 0, 10], projection="X10c/10c", frame="a", - x = [2,4], - y = [8,1], - direction = [[-45,23],[6,3]], + x=[2, 4], + y=[8, 1], + direction=[[-45, 23], [6, 3]], style="v0.6c+e", pen="2p", color="red3", @@ -110,7 +110,7 @@ # Create a list of lists that include each vector information vectors = np.array([vector_1] + [vector_2]) print(vectors) -# vectors structure: +# vectors structure: # [[ 2. 3. 45. 4. ] # [ 7.5 8.3 -120.5 7.2]] From 066dffb1a7496edf14ae24d8b520c2c722e852ea Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 20 Mar 2021 18:52:14 -0400 Subject: [PATCH 14/75] add two new examples. Description needed --- examples/tutorials/vectors.py | 83 ++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index a835993b86c..0c3c8fdce8e 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -38,7 +38,7 @@ fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", - frame="a", + frame="ag", x=2, y=8, direction=[[-45], [6]], @@ -61,7 +61,7 @@ fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", - frame="a", + frame="ag", x=[2, 4], y=[8, 1], direction=[[-45, 23], [6, 3]], @@ -90,7 +90,7 @@ fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", - frame="a", + frame="ag", data=vectors, style="v0.6c+e", pen="2p", @@ -109,7 +109,6 @@ vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information vectors = np.array([vector_1] + [vector_2]) -print(vectors) # vectors structure: # [[ 2. 3. 45. 4. ] # [ 7.5 8.3 -120.5 7.2]] @@ -118,7 +117,7 @@ fig.plot( region=[0, 10, 0, 10], projection="X10c/10c", - frame="a", + frame="ag", data=vectors, style="v0.6c+e", pen="2p", @@ -126,6 +125,80 @@ ) fig.show() +######################################################################################## +# More Complicated example with maps TODO: add extensive description + +# create a plot with coast, Mercator projection (M) over the continental US +fig = pygmt.Figure() +fig.coast( + region=[-127, -64, 24, 53], + projection="M15c", + frame="ag", + borders=1, + area_thresh=4000, + shorelines="0.25p,black", + land="grey", + water="lightblue", +) + +style = "v0.6c+bc+ea+a30" +fig.plot( + x=-110, + y=40, + style=style, + pen="1p", + color="red3", + direction=[[-25], [3]] +) + +# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +vector_2 = [-82, 40.5, 138, 3] +vector_3 = [-71.2, 45, -115.7, 6] +# Create a list of lists that include each vector information +vectors = np.array([vector_2] + [vector_3]) + +fig.plot( + data=vectors, + style=style, + pen="1p", + color="yellow", +) + +fig.show() + +######################################################################################## +# More Complicated example with maps TODO: add extensive description + +# create a plot with coast, Mercator projection (M) over the continental US +fig = pygmt.Figure() +fig.coast( + region=[20, 50, 30, 45], + projection="T35/12c", + frame=True, + borders=1, + area_thresh=4000, + shorelines="0.25p,black", + land="lightbrown", + water="lightblue", +) + +x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] +y = np.linspace(39, 39, 5) # y values = [39. 39. 39. 39.] +direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] +length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] + +fig.plot( + x=x, + y=y, + style="v0.4c+ea", + pen="0.6p", + color="red3", + direction=[direction, length] +) + + +fig.show() + ######################################################################################## # # Plot Circular Vectors # ---------- From d2ab6f992838e5f7ba4ba1e202b9513aadc21103 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 20 Mar 2021 18:55:49 -0400 Subject: [PATCH 15/75] Fix style issues --- examples/tutorials/vectors.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 0c3c8fdce8e..4840cfbbeb0 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -148,7 +148,7 @@ style=style, pen="1p", color="red3", - direction=[[-25], [3]] + direction=[[-25], [3]], ) # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] @@ -182,10 +182,10 @@ water="lightblue", ) -x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] -y = np.linspace(39, 39, 5) # y values = [39. 39. 39. 39.] -direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] -length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] +x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] +y = np.linspace(39, 39, 5) # y values = [39. 39. 39. 39.] +direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] +length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] fig.plot( x=x, @@ -193,7 +193,7 @@ style="v0.4c+ea", pen="0.6p", color="red3", - direction=[direction, length] + direction=[direction, length], ) From c3f9cbb7c91b983d285dfcbae1ee22aa27ef005f Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sun, 21 Mar 2021 13:14:14 -0400 Subject: [PATCH 16/75] Add unit descriptions --- examples/tutorials/vectors.py | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 4840cfbbeb0..56302bdb180 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -27,8 +27,11 @@ # ``x``, ``y``, and ``direction`` parameters. The direction is specified # by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` # -# On the shown figure, the plot is projected on a _10X10_ region, +# On the shown figure, the plot is projected on a _10cm X 10cm_ region, # which is specified by the `region` and `projection` parameters. +# The magnitude of the vector also uses centimeters by default but +# could be changed using [pygmt.config](https://www.pygmt.org/latest/api/generated/pygmt.config.html#pygmt-config) +# (Check the next examples for unit changes) # # Notice that the ``v`` in the ``style`` parameter stands for # vector; it distinguishes it from regular lines and allows for @@ -71,6 +74,41 @@ ) fig.show() +######################################################################################## +# The default unit of vector magnitude/length is centimeters. +# However, this can be changed to inches or points. Note that, in GMT, +# one point is defined as 1/72 inch. +# +# In this example, the graphed region is _10in X 10in_, however, +# the magnitude of the first vector is still graphed in centimeters. +# Using ``pygmt.config(PROJ_LENGTH_UNIT="i")``, the default unit +# can be changed to inches in the second plotted vector. + +fig = pygmt.Figure() +# Vector 1 with default unit as cm +fig.plot( + region=[0, 10, 0, 10], + projection="X10i/10i", + frame="ag", + x=2, + y=8, + direction=[[0], [3]], + style="v1c+e", + pen="2p", + color="red3", +) +# Vector 2 after changing default unit to in +with pygmt.config(PROJ_LENGTH_UNIT="i"): + fig.plot( + x=2, + y=7, + direction=[[0], [3]], + style="v1c+e", + pen="2p", + color="red3", +) +fig.show() + ######################################################################################## # Vectors can also be plotted by including all the information # about a vector in a single list. However, this requires creating From bba843ae8e8f0210ee62ef15c80285a11d45cf7b Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sun, 21 Mar 2021 13:45:47 -0400 Subject: [PATCH 17/75] add description to vectors over maps --- examples/tutorials/vectors.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 56302bdb180..d1467ee5f62 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -76,7 +76,7 @@ ######################################################################################## # The default unit of vector magnitude/length is centimeters. -# However, this can be changed to inches or points. Note that, in GMT, +# However, this can be changed to inches or points. Note that, in GMT, # one point is defined as 1/72 inch. # # In this example, the graphed region is _10in X 10in_, however, @@ -100,13 +100,13 @@ # Vector 2 after changing default unit to in with pygmt.config(PROJ_LENGTH_UNIT="i"): fig.plot( - x=2, - y=7, - direction=[[0], [3]], - style="v1c+e", - pen="2p", - color="red3", -) + x=2, + y=7, + direction=[[0], [3]], + style="v1c+e", + pen="2p", + color="red3", + ) fig.show() ######################################################################################## @@ -164,7 +164,9 @@ fig.show() ######################################################################################## -# More Complicated example with maps TODO: add extensive description +# In this example, cartesian vectors are plotted over a Mercator +# projection of the continental US. The x values represent the +# longitude and y values represent the latitude where the vector starts # create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() @@ -205,7 +207,9 @@ fig.show() ######################################################################################## -# More Complicated example with maps TODO: add extensive description +# Another example of plotting cartesian vectors over a coast plot. This time +# a Transverse Mercator projection is used. Additionally, ``numpy.linespace`` +# is used to create 5 vectors with equal stops. # create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() From a34570f48779216b13d179736be30e43678bd3cb Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sun, 21 Mar 2021 18:14:16 -0400 Subject: [PATCH 18/75] update method reference to use :meth: --- examples/tutorials/vectors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index d1467ee5f62..5c18114a437 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -30,7 +30,7 @@ # On the shown figure, the plot is projected on a _10cm X 10cm_ region, # which is specified by the `region` and `projection` parameters. # The magnitude of the vector also uses centimeters by default but -# could be changed using [pygmt.config](https://www.pygmt.org/latest/api/generated/pygmt.config.html#pygmt-config) +# could be changed using :meth:`pygmt.config` # (Check the next examples for unit changes) # # Notice that the ``v`` in the ``style`` parameter stands for @@ -275,6 +275,7 @@ ######################################################################################## # FIXME: Everything after this is from ``lines.py`` and must be removed +# # Additional line segments can be added by including additional values for ``x`` # and ``y``. From 6cf34197c5858e09924e93dc4e99a8eca17b38e1 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sun, 21 Mar 2021 18:18:46 -0400 Subject: [PATCH 19/75] remove whitespace to fix style issue --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 5c18114a437..6ac529c8cfd 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -275,7 +275,7 @@ ######################################################################################## # FIXME: Everything after this is from ``lines.py`` and must be removed -# +# # Additional line segments can be added by including additional values for ``x`` # and ``y``. From 60153715ec902c12f9b2d9a6a63afddd33b3de95 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:40:17 -0400 Subject: [PATCH 20/75] remove italics, clarify projection parameter --- examples/tutorials/vectors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 6ac529c8cfd..e365a2cec52 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -27,8 +27,8 @@ # ``x``, ``y``, and ``direction`` parameters. The direction is specified # by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` # -# On the shown figure, the plot is projected on a _10cm X 10cm_ region, -# which is specified by the `region` and `projection` parameters. +# On the shown figure, the plot is projected on a 10cm X 10cm region, +# which is specified by the ``projection`` parameter. # The magnitude of the vector also uses centimeters by default but # could be changed using :meth:`pygmt.config` # (Check the next examples for unit changes) @@ -79,7 +79,7 @@ # However, this can be changed to inches or points. Note that, in GMT, # one point is defined as 1/72 inch. # -# In this example, the graphed region is _10in X 10in_, however, +# In this example, the graphed region is 10in X 10in, however, # the magnitude of the first vector is still graphed in centimeters. # Using ``pygmt.config(PROJ_LENGTH_UNIT="i")``, the default unit # can be changed to inches in the second plotted vector. @@ -140,7 +140,7 @@ # Using the functionality mentioned in the previous example, # multiple vectors can be plotted at the same time. Another # vector could be simply added to the 2d ``numpy`` array object -# and passed using `data` parameter. +# and passed using ``data`` parameter. # vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] vector_1 = [2, 3, 45, 4] From d7aaad54f749ecf14bf63106c85bbe656f5abd7e Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 22 Mar 2021 12:50:23 -0400 Subject: [PATCH 21/75] change example projection to 10 X 4 --- examples/tutorials/vectors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index e365a2cec52..1fb0ec8cd0c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -79,7 +79,7 @@ # However, this can be changed to inches or points. Note that, in GMT, # one point is defined as 1/72 inch. # -# In this example, the graphed region is 10in X 10in, however, +# In this example, the graphed region is 10in X 4in, however, # the magnitude of the first vector is still graphed in centimeters. # Using ``pygmt.config(PROJ_LENGTH_UNIT="i")``, the default unit # can be changed to inches in the second plotted vector. @@ -88,8 +88,8 @@ # Vector 1 with default unit as cm fig.plot( region=[0, 10, 0, 10], - projection="X10i/10i", - frame="ag", + projection="X10i/4i", + frame="a", x=2, y=8, direction=[[0], [3]], From bf53a8d86a20a2a88846176b971bd79bc65e9b22 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Mon, 22 Mar 2021 21:59:24 -0400 Subject: [PATCH 22/75] Updated diameter to radius to fix previous mistake --- examples/tutorials/vectors.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 8843f8b7ca4..b8a1ea372da 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -45,12 +45,13 @@ fig.show() ######################################################################################## -# Circular vectors can be plotted using an ``x`` and ``y`` value to specify -# where the origin of the circle will be located on the plane. The variable -# ``diam`` is used to specify the diameter of the circle while the ``startDeg`` and -# ``stopDeg`` specify at what angle the arc will begin and end respectively. +# Circular vectors can be plotted using an ``x_start`` and ``y_start`` value to +# specify where the origin of the circle will be located on the plane. The +# variable ``radius`` is used to specify the radius of the circle while the +# ``degree_start`` and ``degree_stop`` parameters specify at what angle the arc +# will begin and end respectively. -# vector specifications structured as: [x_start, y_start, diameter, degree_start, degree_stop] +# vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] data = np.array([[5, 5, 2.5, 90, 270]]) fig = pygmt.Figure() From ad213eac38f325a2b71d2e5fb4b2f44092928ddb Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 24 Mar 2021 14:02:34 -0400 Subject: [PATCH 23/75] Add some geographic vectors to test --- Untitled.ipynb | 59 ++++++++++++++++ Untitled1.ipynb | 107 ++++++++++++++++++++++++++++++ examples/tutorials/Untitled.ipynb | 53 +++++++++++++++ examples/tutorials/vectors.py | 106 +++++++++++++++++++++++++++++ 4 files changed, 325 insertions(+) create mode 100644 Untitled.ipynb create mode 100644 Untitled1.ipynb create mode 100644 examples/tutorials/Untitled.ipynb diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 00000000000..c52ef6bea7a --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "matched-coating", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'xarray'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow_versions\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;31m# Import modules to make the high-level GMT Python API\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTDataArrayAccessor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/datasets/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Load sample data included with GMT (downloaded from the GMT cache server).\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mearth_relief\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mload_earth_relief\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m from pygmt.datasets.tutorial import (\n\u001b[1;32m 7\u001b[0m \u001b[0mload_japan_quakes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/datasets/earth_relief.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mThe\u001b[0m \u001b[0mgrids\u001b[0m \u001b[0mare\u001b[0m \u001b[0mavailable\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvarious\u001b[0m \u001b[0mresolutions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \"\"\"\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mxarray\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mxr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexceptions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTInvalidInput\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhelpers\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkwargs_to_strings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'xarray'" + ] + } + ], + "source": [ + "import pygmt\n", + "pygmt.show_versions()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "floating-momentum", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Untitled1.ipynb b/Untitled1.ipynb new file mode 100644 index 00000000000..1a4c073e1a6 --- /dev/null +++ b/Untitled1.ipynb @@ -0,0 +1,107 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'xarray'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;31m# Import modules to make the high-level GMT Python API\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTDataArrayAccessor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/datasets/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Load sample data included with GMT (downloaded from the GMT cache server).\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mearth_relief\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mload_earth_relief\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m from pygmt.datasets.tutorial import (\n\u001b[1;32m 7\u001b[0m \u001b[0mload_japan_quakes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/datasets/earth_relief.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mThe\u001b[0m \u001b[0mgrids\u001b[0m \u001b[0mare\u001b[0m \u001b[0mavailable\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvarious\u001b[0m \u001b[0mresolutions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \"\"\"\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mxarray\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mxr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexceptions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTInvalidInput\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhelpers\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkwargs_to_strings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'xarray'" + ] + } + ], + "source": [ + "import numpy as np\n", + "import pygmt\n", + "\n", + "from pygmt import datasets\n", + "from pygmt.figure import Figure\n", + "from pygmt.modules import GMTDataArrayAccessor, config\n", + "\n", + "vector_1 = [2, 3, 45, 4]\n", + "vector_2 = [7.5, 8.3, -120.5, 7.2]\n", + "# Create a list of lists that include each vector information\n", + "data = np.array([vector_1] + [vector_2])\n", + "\n", + "fig = pygmt.Figure()\n", + "fig.plot(\n", + " region=[0, 10, 0, 10],\n", + " projection=\"X10c/10c\",\n", + " frame=\"a\",\n", + " data=data,\n", + " style=\"v0.6c+e\",\n", + " pen=\"2p\",\n", + " color=\"red3\",\n", + ")\n", + "fig.show()\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/tutorials/Untitled.ipynb b/examples/tutorials/Untitled.ipynb new file mode 100644 index 00000000000..ced20741852 --- /dev/null +++ b/examples/tutorials/Untitled.ipynb @@ -0,0 +1,53 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "molecular-weapon", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pygmt'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumoy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mfig\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mfog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbasemap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mregion\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m15\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m15\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprojection\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"X15c/10c\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mframe\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pygmt'" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "universal-shell", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 0786c2b47cd..08468f63350 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -266,6 +266,8 @@ ) fig.show() + + ######################################################################################## # FIXME: Everything after this is from ``lines.py`` and must be removed # @@ -369,3 +371,107 @@ pen="7p,green,-.-", ) fig.show() + +######################################################################################## +# # Plot Geographic Vectors +# ---------- + +fig = pygmt.Figure() +fig.plot( + region=[0, 8, 0, 8], + projection="X10c/10c", + frame="a", + data=data, + style="m0.5c+ea", + pen="2p", + color="red3", +) +fig.show() + +######################################################################################## +# Georgraphic Vector using the `fig.coast` of the region of the United States. +# The plotting of the georgraphic vectors when using latitude and longitude +# are labeled by having Latitude negative, coming first and longitude come second. +# Then and array is created to create the vectors to follow the one before. +import pygmt +import numpy as np +fig = pygmt.Figure() +fig.coast( + region=[-127, -64, 24, 53], + projection="M15c", + frame=True, + borders=1, + area_thresh=4000, + shorelines="0.25p,black", +) +# Plot geographic vectors using latitude and longitude. +ME = [-69.4455, 45.2538] +CHI = [-87.6298, 41.8781] +SEA = [-122.3321, 47.6062] +NO = [-90.0715, 29.9511] +KC = [-94.5786, 39.0997] +CA = [-119.4179, 36.7783] +# Add array to piece together the vectors. +data = np.array([ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA]) +fig.plot( + data=data, + style="=0.5c+ea+s", + pen="2p", + color="red3", +) +fig.show() +######################################################################################## +# Geographic graph using x and y values to set a start and an ending point. +# Use `fig.coast` to display the ouput of a coast. `x` and `y` are cordinates +# on a grid. `x` which is Idaho and `y` is chicago. The geographical vector +# is going from Idaho to Chicago. + +import pygmt +import numpy as np +fig = pygmt.Figure() +fig.coast( + region=[-127, -64, 24, 53], + projection="M15c", + frame=True, + borders=1, + area_thresh=4000, + shorelines="0.25p,black", +) +x = [-114.7420, 44.0682] +y = [-87.6298, 41.8781] +data = np.array([x + y]) + +fig.plot( + data=data, + style="=0.5c+ea+s", + pen="2p", + color="red3", +) +fig.show() + +################################################################################# + +import pygmt +import numpy as np + +fig = pygmt.Figure() +fig.coast( + shorelines="1/0.5p", + region=[-180, -20, 0, 90], + projection="Poly/12c", + land="gray", + borders="1/thick,black", + frame="afg10", +) +x = [-99.1332, 19.4326] +y = [-69.4455, 45.2538] +z = [-122.5210, 47.6249] +data = np.array([x + y, y + z]) + +fig.plot( + data=data, + style="=0.5c+ea+s", + pen="2p", + color="red3", +) +fig.show() From 5b731099c0a9a46607a46c8be6cf34a6c66edbdd Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Wed, 24 Mar 2021 14:05:02 -0400 Subject: [PATCH 24/75] try sphinx reference fix --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 1fb0ec8cd0c..6b888b1c29b 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -58,7 +58,7 @@ # Additionally, we changed the style of the vector to include a red # arrowhead and increased the thickness of the line. A list of different # styling attributes can be found in -# [Vector attributes documentation](https://www.pygmt.org/latest/gallery/lines/vector_heads_tails.html) +# :doc:`Vector heads and tails ` fig = pygmt.Figure() fig.plot( From 4321fb56c3b2239b714a8f29962a01ac3e1692cb Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 24 Mar 2021 14:09:13 -0400 Subject: [PATCH 25/75] Updated example description --- examples/tutorials/vectors.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 0786c2b47cd..edb3183ffa9 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -245,21 +245,26 @@ # # Plot Circular Vectors # ---------- # -# Circular vectors can be plotted using an ``x_start`` and ``y_start`` value to -# specify where the origin of the circle will be located on the plane. The -# variable ``radius`` is used to specify the radius of the circle while the -# ``degree_start`` and ``degree_stop`` parameters specify at what angle the arc -# will begin and end respectively. +# When plotting circular vectors, there are 5 values that should be included in +# the list that is passed through np.array() in order to create a valid plot. +# The first two values in ``circular_vector_1`` represent the origin of the +# circle that will be plotted. The next value is the radius which is represented +# on the plot in centimeters. Finally, the last two values represent the degree +# at which the plot will start and stop. In this example, the result show is the +# left half of a circle as the plot starts at 90 degrees and goes until 270. # vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] -data = np.array([[4, 4, 2, 90, 270]]) +circular_vector_1 = [0, 0, 5, 90, 270] + +data = np.array([circular_vector_1]) fig = pygmt.Figure() fig.plot( - region=[0, 8, 0, 8], - projection="X10c/10c", - frame="a", + region=[-10, 10, -10, 10], + projection="X20c", + frame="ag", data=data, + # when plotting circular vectors the style variable should begin with m style="m0.5c+ea", pen="2p", color="red3", From a3ec8cd3dde70930d4998128429640f510035279 Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 24 Mar 2021 14:22:43 -0400 Subject: [PATCH 26/75] Erase lines and move around geo vectors --- examples/tutorials/vectors.py | 162 +++++----------------------------- 1 file changed, 23 insertions(+), 139 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 08468f63350..6d266e8c3d9 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -266,123 +266,33 @@ ) fig.show() - - -######################################################################################## -# FIXME: Everything after this is from ``lines.py`` and must be removed -# -# Additional line segments can be added by including additional values for ``x`` -# and ``y``. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 6, 9], - y=[5, 7, 4], - pen="1p,black", -) -fig.show() - -######################################################################################## -# To plot multiple lines, :meth:`pygmt.Figure.plot` needs to be used for each -# additional line. Arguments such as ``region``, ``projection``, and ``frame`` do -# not need to be repeated in subsequent uses. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 6, 9], - y=[5, 7, 4], - pen="2p,blue", -) -fig.plot(x=[2, 4, 10], y=[3, 8, 9], pen="2p,red") -fig.show() - -######################################################################################## -# Change line attributes -# ---------------------- -# -# The line attributes can be set by the ``pen`` parameter. ``pen`` takes a string -# argument with the optional values *width*,\ *color*,\ *style*. -# -# In the example below, the pen width is set to ``5p``, and with ``black`` as the -# default color and ``solid`` as the default style. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 8], - y=[3, 9], - pen="5p", -) -fig.show() - -######################################################################################## -# The line color can be set and is added after the line width to the ``pen`` parameter. -# In the example below, the line color is set to ``red``. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 8], - y=[3, 9], - pen="5p,red", -) -fig.show() - -######################################################################################## -# The line style can be set and is added after the line width or color to the -# ``pen`` parameter. In the example below, the line style is set to -# ``..-`` (*dot dot dash*), and the default color ``black`` is used. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 8], - y=[3, 9], - pen="5p,..-", -) -fig.show() - -######################################################################################## -# The line width, color, and style can all be set in the same ``pen`` parameter. In the -# example below, the line width is set to ``7p``, the color is set to ``green``, and the -# line style is ``-.-`` (*dash dot dash*). -# -# For a gallery showing other ``pen`` settings, see :doc:`/gallery/lines/linestyles`. - -fig = pygmt.Figure() -fig.plot( - region=[0, 10, 0, 10], - projection="X25c/20c", - frame="a", - x=[1, 8], - y=[3, 9], - pen="7p,green,-.-", -) -fig.show() - ######################################################################################## # # Plot Geographic Vectors # ---------- +# Geographic graph using x and y values to set a start and an ending point. +# Use `fig.coast` to display the ouput of a coast. `x` and `y` are cordinates +# on a grid. `x` which is Idaho and `y` is chicago. The geographical vector +# is going from Idaho to Chicago. The style of geographic vectors use `=` at the +# begining to refer it to geographic. +import pygmt +import numpy as np fig = pygmt.Figure() +fig.coast( + region=[-127, -64, 24, 53], + projection="M15c", + frame=True, + borders=1, + area_thresh=4000, + shorelines="0.25p,black", +) +x = [-114.7420, 44.0682] +y = [-87.6298, 41.8781] +data = np.array([x + y]) + fig.plot( - region=[0, 8, 0, 8], - projection="X10c/10c", - frame="a", data=data, - style="m0.5c+ea", + style="=0.5c+ea+s", pen="2p", color="red3", ) @@ -392,7 +302,7 @@ # Georgraphic Vector using the `fig.coast` of the region of the United States. # The plotting of the georgraphic vectors when using latitude and longitude # are labeled by having Latitude negative, coming first and longitude come second. -# Then and array is created to create the vectors to follow the one before. +# Then and array is created to create the vectors to follow the one before. import pygmt import numpy as np fig = pygmt.Figure() @@ -413,34 +323,6 @@ CA = [-119.4179, 36.7783] # Add array to piece together the vectors. data = np.array([ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA]) -fig.plot( - data=data, - style="=0.5c+ea+s", - pen="2p", - color="red3", -) -fig.show() -######################################################################################## -# Geographic graph using x and y values to set a start and an ending point. -# Use `fig.coast` to display the ouput of a coast. `x` and `y` are cordinates -# on a grid. `x` which is Idaho and `y` is chicago. The geographical vector -# is going from Idaho to Chicago. - -import pygmt -import numpy as np -fig = pygmt.Figure() -fig.coast( - region=[-127, -64, 24, 53], - projection="M15c", - frame=True, - borders=1, - area_thresh=4000, - shorelines="0.25p,black", -) -x = [-114.7420, 44.0682] -y = [-87.6298, 41.8781] -data = np.array([x + y]) - fig.plot( data=data, style="=0.5c+ea+s", @@ -475,3 +357,5 @@ color="red3", ) fig.show() + +################################################################################ From ecbed604521553152108e33d1025c9664eaf5ef1 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 24 Mar 2021 14:59:28 -0400 Subject: [PATCH 27/75] Added multiple vector example --- Pipfile | 15 +++++++++++++++ examples/tutorials/vectors.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Pipfile diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000000..adcf24a71ca --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +numpy = "*" +pandas = "*" +xarray = "*" +netCDF4 = "*" + +[dev-packages] + +[requires] +python_version = "3.8" diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index edb3183ffa9..15ae19ab8ed 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -271,6 +271,36 @@ ) fig.show() +######################################################################################## +# When plotting multiple vectors there is a multitude of ``numpy`` functions +# that can make this process easier. In the following example, three main numpy +# functions are used. The first of which is ``np.arange`` which iterates from 0 +# to the value of ct. This function is used to generate random data points for +# ``radius`` and ``stopdir`` since these values are intended to be different in +# each of the five vectors begin plotted. The second function is ``np.full`` +# which creates a numpy.ndarray. Finally, all of this data is congregated into +# a final numpy.ndarray called data using ``np.column_stack``. This is then +# passed to the plot function and the resulting figure is shown below. + +ct = 5 +radius = 5 - (0.5 * np.arange(0, ct)) +startdir = np.full(ct, 90) +stopdir = 180 + (50 * np.arange(0, ct)) + +data = np.column_stack([np.full(ct, 0), np.full(ct, 0), radius, startdir, stopdir]) + +fig = pygmt.Figure() +fig.plot( + region=[-10, 10, -10, 10], + projection="X20c", + frame="ag", + data=data, + style="m0.5c+ea", + pen="2p", + color="red3", +) +fig.show() + ######################################################################################## # FIXME: Everything after this is from ``lines.py`` and must be removed # From 74556ab5fd16f64620894cb75171848cd07384ca Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 24 Mar 2021 14:59:47 -0400 Subject: [PATCH 28/75] Added multiple vector example --- Pipfile | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Pipfile diff --git a/Pipfile b/Pipfile deleted file mode 100644 index adcf24a71ca..00000000000 --- a/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -numpy = "*" -pandas = "*" -xarray = "*" -netCDF4 = "*" - -[dev-packages] - -[requires] -python_version = "3.8" From 94c8968cbf3fbd81f3cc05a9589de1f8392d3b03 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 24 Mar 2021 20:43:34 -0400 Subject: [PATCH 29/75] Added style description to paragraph rather than a comment. --- examples/tutorials/vectors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 15ae19ab8ed..e51c011938a 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -252,6 +252,8 @@ # on the plot in centimeters. Finally, the last two values represent the degree # at which the plot will start and stop. In this example, the result show is the # left half of a circle as the plot starts at 90 degrees and goes until 270. +# It is important to note that when plotting circular vectors, the style value +# should begin with an ``m``. # vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] circular_vector_1 = [0, 0, 5, 90, 270] @@ -264,7 +266,6 @@ projection="X20c", frame="ag", data=data, - # when plotting circular vectors the style variable should begin with m style="m0.5c+ea", pen="2p", color="red3", From 7d626ac9b1b02570eb3ad3ff36c15fa04ea48f3e Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Wed, 24 Mar 2021 20:51:40 -0400 Subject: [PATCH 30/75] delete first untitled file --- Untitled.ipynb | 59 -------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 Untitled.ipynb diff --git a/Untitled.ipynb b/Untitled.ipynb deleted file mode 100644 index c52ef6bea7a..00000000000 --- a/Untitled.ipynb +++ /dev/null @@ -1,59 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "matched-coating", - "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'xarray'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow_versions\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;31m# Import modules to make the high-level GMT Python API\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTDataArrayAccessor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/datasets/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Load sample data included with GMT (downloaded from the GMT cache server).\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mearth_relief\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mload_earth_relief\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m from pygmt.datasets.tutorial import (\n\u001b[1;32m 7\u001b[0m \u001b[0mload_japan_quakes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/MappingTool/pygmt/pygmt/datasets/earth_relief.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mThe\u001b[0m \u001b[0mgrids\u001b[0m \u001b[0mare\u001b[0m \u001b[0mavailable\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvarious\u001b[0m \u001b[0mresolutions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \"\"\"\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mxarray\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mxr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexceptions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTInvalidInput\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhelpers\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkwargs_to_strings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'xarray'" - ] - } - ], - "source": [ - "import pygmt\n", - "pygmt.show_versions()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "floating-momentum", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.3" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From d5a320c657c6519d29087d86c5a2579a4581c042 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Wed, 24 Mar 2021 20:52:01 -0400 Subject: [PATCH 31/75] Delete Untitled1.ipynb --- Untitled1.ipynb | 107 ------------------------------------------------ 1 file changed, 107 deletions(-) delete mode 100644 Untitled1.ipynb diff --git a/Untitled1.ipynb b/Untitled1.ipynb deleted file mode 100644 index 1a4c073e1a6..00000000000 --- a/Untitled1.ipynb +++ /dev/null @@ -1,107 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'xarray'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;31m# Import modules to make the high-level GMT Python API\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTDataArrayAccessor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/datasets/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Load sample data included with GMT (downloaded from the GMT cache server).\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mearth_relief\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mload_earth_relief\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m from pygmt.datasets.tutorial import (\n\u001b[1;32m 7\u001b[0m \u001b[0mload_japan_quakes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/CS 481/pyGMT/pygmt/pygmt/datasets/earth_relief.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mThe\u001b[0m \u001b[0mgrids\u001b[0m \u001b[0mare\u001b[0m \u001b[0mavailable\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvarious\u001b[0m \u001b[0mresolutions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \"\"\"\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mxarray\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mxr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexceptions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mGMTInvalidInput\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhelpers\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkwargs_to_strings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'xarray'" - ] - } - ], - "source": [ - "import numpy as np\n", - "import pygmt\n", - "\n", - "from pygmt import datasets\n", - "from pygmt.figure import Figure\n", - "from pygmt.modules import GMTDataArrayAccessor, config\n", - "\n", - "vector_1 = [2, 3, 45, 4]\n", - "vector_2 = [7.5, 8.3, -120.5, 7.2]\n", - "# Create a list of lists that include each vector information\n", - "data = np.array([vector_1] + [vector_2])\n", - "\n", - "fig = pygmt.Figure()\n", - "fig.plot(\n", - " region=[0, 10, 0, 10],\n", - " projection=\"X10c/10c\",\n", - " frame=\"a\",\n", - " data=data,\n", - " style=\"v0.6c+e\",\n", - " pen=\"2p\",\n", - " color=\"red3\",\n", - ")\n", - "fig.show()\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} From e9f16fc7067cee544681ffcd26aaabdd8b8b12ea Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Wed, 24 Mar 2021 20:52:22 -0400 Subject: [PATCH 32/75] Delete Untitled.ipynb --- examples/tutorials/Untitled.ipynb | 53 ------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 examples/tutorials/Untitled.ipynb diff --git a/examples/tutorials/Untitled.ipynb b/examples/tutorials/Untitled.ipynb deleted file mode 100644 index ced20741852..00000000000 --- a/examples/tutorials/Untitled.ipynb +++ /dev/null @@ -1,53 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "id": "molecular-weapon", - "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'pygmt'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumoy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mfig\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpygmt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mfog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbasemap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mregion\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m15\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m15\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprojection\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"X15c/10c\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mframe\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pygmt'" - ] - } - ], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "universal-shell", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.3" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From 7249ac566049227b89ecb5c87ceb23941868057e Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 24 Mar 2021 20:55:56 -0400 Subject: [PATCH 33/75] Added new example plotting two vectors using different units --- examples/tutorials/vectors.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index e51c011938a..307564974ec 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -302,6 +302,38 @@ ) fig.show() +######################################################################################## +# Much like when plotting regular vectors, the default unit used is centimeters. +# When this is changed to inches, the size of the plot appears larger when the +# projection units do not change. Below is an example of two circular vectors. +# One is plotted using the default unit, and the second is plotted using inches. +# The difference in size of the two vectors provides good insignt into how this +# functionality works. + +circular_vector_1 = [0, 0, 5, 90, 270] +circular_vector_2 = [0, 0, 5, 90, 270] + +data_1 = np.array([circular_vector_1]) +fig.plot( + region=[-15, 15, -15, 15], + projection="X30c", + frame="ag", + data=data_1, + style="m0.5c+ea", + pen="2p", + color="red3", +) + +data_2 = np.array([circular_vector_2]) +with pygmt.config(PROJ_LENGTH_UNIT="i"): + fig.plot( + data=data_2, + style="m0.5c+ea", + pen="2p", + color="red3", + ) +fig.show() + ######################################################################################## # FIXME: Everything after this is from ``lines.py`` and must be removed # From f0fa6ada078a4aa9d206ac3ba617c34b1537e13d Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 24 Mar 2021 22:25:36 -0400 Subject: [PATCH 34/75] Add description and vector --- examples/tutorials/vectors.py | 42 ++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 6d266e8c3d9..27244c795f5 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -301,7 +301,7 @@ ######################################################################################## # Georgraphic Vector using the `fig.coast` of the region of the United States. # The plotting of the georgraphic vectors when using latitude and longitude -# are labeled by having Latitude negative, coming first and longitude come second. +# are labeled by having the coordinates displayed. # Then and array is created to create the vectors to follow the one before. import pygmt import numpy as np @@ -314,7 +314,7 @@ area_thresh=4000, shorelines="0.25p,black", ) -# Plot geographic vectors using latitude and longitude. +# Plot geographic vectors using coordinates. ME = [-69.4455, 45.2538] CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] @@ -332,7 +332,10 @@ fig.show() ################################################################################# - +# This is a polyconic projection of geographic vectors. This projection +# is set to poly. The MC, ME, WA variables are connected to Mexico City (MC) +# Maine (ME), and Washington (WA). Each variable has a coordinate corrensponding +# that place. import pygmt import numpy as np @@ -345,9 +348,9 @@ borders="1/thick,black", frame="afg10", ) -x = [-99.1332, 19.4326] -y = [-69.4455, 45.2538] -z = [-122.5210, 47.6249] +MC = [-99.1332, 19.4326] +ME = [-69.4455, 45.2538] +WA = [-122.5210, 47.6249] data = np.array([x + y, y + z]) fig.plot( @@ -359,3 +362,30 @@ fig.show() ################################################################################ +# This geogrpahic vector is using the `Mercator` projection. For this we have +#`fig.coast` with the region, frame, land and projection type. Then for the vector +# points we are starting at SA which is South Africa and going to four different +# places. + +import pygmt + +fig = pygmt.Figure() +fig.coast(region=[0, 360, -80, 80], + frame="afg", + land="red", + projection="M0/0/12c" +) +SA = [22.9375, -30.5595] +EUR = [15.2551, 54.5260] +ME = [-69.4455, 45.2538] +AS = [100.6197, 34.0479] +NM = [-105.8701, 34.5199] +data = np.array([SA + EUR, SA + ME, SA + AS, SA + NM]) + +fig.plot( + data=data, + style="=0.5c+ea+s", + pen="2p", + color="red3", +) +fig.show() From 4b4a094a807f53d1cfdca72c7d48cc2df6459c91 Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 24 Mar 2021 23:07:50 -0400 Subject: [PATCH 35/75] Fix descriptions --- examples/tutorials/vectors.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 27244c795f5..282e62be303 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -270,10 +270,12 @@ # # Plot Geographic Vectors # ---------- # Geographic graph using x and y values to set a start and an ending point. -# Use `fig.coast` to display the ouput of a coast. `x` and `y` are cordinates -# on a grid. `x` which is Idaho and `y` is chicago. The geographical vector -# is going from Idaho to Chicago. The style of geographic vectors use `=` at the -# begining to refer it to geographic. +# Use `fig.coast` to display the output of a coast. `x` and `y` are cordinates +# on a grid that we are using. `x` is Idaho and `y` is chicago in this example. +# The geographical vector is going from Idaho to Chicago. To style geographic +# vectors, use `=` at the begining to refer it to geographic. `Fig.plot` is where +# you can style your vector. As you can see the vector is red and has the style +# of a geographic vector. import pygmt import numpy as np @@ -299,10 +301,11 @@ fig.show() ######################################################################################## -# Georgraphic Vector using the `fig.coast` of the region of the United States. +# This Georgraphic Vector is using the `fig.coast` of the region of the United States. # The plotting of the georgraphic vectors when using latitude and longitude # are labeled by having the coordinates displayed. -# Then and array is created to create the vectors to follow the one before. +# Then an array is created so the vectors follow the one vector before it. You +# can diplay this array any way you want. import pygmt import numpy as np fig = pygmt.Figure() @@ -335,7 +338,7 @@ # This is a polyconic projection of geographic vectors. This projection # is set to poly. The MC, ME, WA variables are connected to Mexico City (MC) # Maine (ME), and Washington (WA). Each variable has a coordinate corrensponding -# that place. +# that place. import pygmt import numpy as np From ca85046fecfc410ce1e3bf5868941da15db49b83 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 25 Mar 2021 00:02:07 -0400 Subject: [PATCH 36/75] fix typos, remove imports, fix graph --- examples/tutorials/vectors.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 282e62be303..99447fa79ab 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -270,15 +270,13 @@ # # Plot Geographic Vectors # ---------- # Geographic graph using x and y values to set a start and an ending point. -# Use `fig.coast` to display the output of a coast. `x` and `y` are cordinates +# Use `fig.coast` to display the output of a coast. `x` and `y` are coordinates # on a grid that we are using. `x` is Idaho and `y` is chicago in this example. # The geographical vector is going from Idaho to Chicago. To style geographic # vectors, use `=` at the begining to refer it to geographic. `Fig.plot` is where # you can style your vector. As you can see the vector is red and has the style # of a geographic vector. -import pygmt -import numpy as np fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], @@ -301,13 +299,12 @@ fig.show() ######################################################################################## -# This Georgraphic Vector is using the `fig.coast` of the region of the United States. -# The plotting of the georgraphic vectors when using latitude and longitude +# This Geographic Vector is using the `fig.coast` of the region of the United States. +# The plotting of the geographic vectors when using latitude and longitude # are labeled by having the coordinates displayed. # Then an array is created so the vectors follow the one vector before it. You # can diplay this array any way you want. -import pygmt -import numpy as np + fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], @@ -339,8 +336,6 @@ # is set to poly. The MC, ME, WA variables are connected to Mexico City (MC) # Maine (ME), and Washington (WA). Each variable has a coordinate corrensponding # that place. -import pygmt -import numpy as np fig = pygmt.Figure() fig.coast( @@ -354,7 +349,7 @@ MC = [-99.1332, 19.4326] ME = [-69.4455, 45.2538] WA = [-122.5210, 47.6249] -data = np.array([x + y, y + z]) +data = np.array([MC + ME, ME + WA]) fig.plot( data=data, @@ -365,19 +360,19 @@ fig.show() ################################################################################ -# This geogrpahic vector is using the `Mercator` projection. For this we have -#`fig.coast` with the region, frame, land and projection type. Then for the vector +# This geographic vector is using the `Mercator` projection. For this we have +# `fig.coast` with the region, frame, land and projection type. Then for the vector # points we are starting at SA which is South Africa and going to four different # places. -import pygmt fig = pygmt.Figure() -fig.coast(region=[0, 360, -80, 80], +fig.coast(region=[-180, 180, -80, 80], frame="afg", - land="red", + land="lightbrown", + water="lightblue", projection="M0/0/12c" -) + ) SA = [22.9375, -30.5595] EUR = [15.2551, 54.5260] ME = [-69.4455, 45.2538] From 6276e2ab90911967a4b55f22abd6b2405e8b7096 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Thu, 25 Mar 2021 11:05:27 -0400 Subject: [PATCH 37/75] Removed extra # from plot circular vectors heading --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index f7792ebba7d..f2b9e7e2128 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -335,7 +335,7 @@ fig.show() ######################################################################################## -# # Plot Geographic Vectors +# Plot Geographic Vectors # ---------- # Geographic graph using x and y values to set a start and an ending point. # Use `fig.coast` to display the output of a coast. `x` and `y` are coordinates From 43ebc6f432e2a733482b763c3327ba52ce6d24a7 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Thu, 25 Mar 2021 11:08:14 -0400 Subject: [PATCH 38/75] Re-formatted vectors.py with black --- examples/tutorials/vectors.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index f2b9e7e2128..9705665f63c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -435,12 +435,13 @@ fig = pygmt.Figure() -fig.coast(region=[-180, 180, -80, 80], - frame="afg", - land="lightbrown", - water="lightblue", - projection="M0/0/12c" - ) +fig.coast( + region=[-180, 180, -80, 80], + frame="afg", + land="lightbrown", + water="lightblue", + projection="M0/0/12c", +) SA = [22.9375, -30.5595] EUR = [15.2551, 54.5260] ME = [-69.4455, 45.2538] From afd6267f19838d2e1a2d92fad56c8b5c09af2bd4 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Thu, 25 Mar 2021 11:13:53 -0400 Subject: [PATCH 39/75] Fixed bug where fig was not reset after #2 --- examples/tutorials/vectors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 9705665f63c..96e024c2343 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -242,7 +242,7 @@ fig.show() ######################################################################################## -# # Plot Circular Vectors +# Plot Circular Vectors # ---------- # # When plotting circular vectors, there are 5 values that should be included in @@ -314,6 +314,8 @@ circular_vector_2 = [0, 0, 5, 90, 270] data_1 = np.array([circular_vector_1]) + +fig = pygmt.Figure() fig.plot( region=[-15, 15, -15, 15], projection="X30c", From 031c5977611efcf5f5bd0200a6155390f5a0b456 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Thu, 25 Mar 2021 11:44:22 -0400 Subject: [PATCH 40/75] Add gallery thumbnail number, remove TODO --- examples/tutorials/vectors.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 96e024c2343..7adca409d62 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -13,8 +13,7 @@ To save the figure, use ``fig.savefig("figname.pdf")`` where ``"figname.pdf"`` is the desired name and file extension for the saved figure. """ -# TODO: change this number to reflect the correct thumbnail -# sphinx_gallery_thumbnail_number = 3 +# sphinx_gallery_thumbnail_number = 6 import numpy as np import pygmt From 5e104138ba3184f9221bd9dfe5409459a20f77cf Mon Sep 17 00:00:00 2001 From: Claire <46755872+cklima616@users.noreply.github.com> Date: Fri, 26 Mar 2021 12:31:24 -0400 Subject: [PATCH 41/75] Update examples/tutorials/vectors.py with contributor suggestion Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 7adca409d62..b29bc5a49b6 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -118,10 +118,8 @@ # If this approach is chosen, ``data`` parameter must be # used instead of ``x``, ``y`` and ``direction``. -vector_1 = [2, 3, 45, 4] # Create a list of lists that include each vector information -vectors = np.array([vector_1]) -# vectors structure: [[ 2 3 45 4]] +vectors = np.array([[2, 3, 45, 4]]) # vectors structure: [[ 2 3 45 4]] fig = pygmt.Figure() fig.plot( From 1f0b2736bc493104c643099f31bde1a1a6c09700 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 26 Mar 2021 13:16:35 -0400 Subject: [PATCH 42/75] fix backtics and add other requested changes --- examples/tutorials/vectors.py | 43 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index b29bc5a49b6..2ac7d7a7b2e 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -28,13 +28,15 @@ # # On the shown figure, the plot is projected on a 10cm X 10cm region, # which is specified by the ``projection`` parameter. -# The magnitude of the vector also uses centimeters by default but +# The length of the vector also uses centimeters by default but # could be changed using :meth:`pygmt.config` # (Check the next examples for unit changes) # # Notice that the ``v`` in the ``style`` parameter stands for # vector; it distinguishes it from regular lines and allows for -# different customization. +# different customization. ``0c`` is used to specify the size +# of the arrowhead which explains why there is no arrow on either +# side of the vector. fig = pygmt.Figure() fig.plot( @@ -74,12 +76,12 @@ fig.show() ######################################################################################## -# The default unit of vector magnitude/length is centimeters. -# However, this can be changed to inches or points. Note that, in GMT, +# The default unit of vector length is centimeters, +# however, this can be changed to inches or points. Note that, in GMT, # one point is defined as 1/72 inch. # -# In this example, the graphed region is 10in X 4in, however, -# the magnitude of the first vector is still graphed in centimeters. +# In this example, the graphed region is 10in X 4in, but +# the length of the first vector is still graphed in centimeters. # Using ``pygmt.config(PROJ_LENGTH_UNIT="i")``, the default unit # can be changed to inches in the second plotted vector. @@ -113,7 +115,7 @@ # about a vector in a single list. However, this requires creating # a list for all vectors and passing it into a ``numpy`` array object. # Each vector list contains the information structured as: -# ``[x_start, y_start, direction_degrees, magnitude]`` +# ``[x_start, y_start, direction_degrees, length]`` # # If this approach is chosen, ``data`` parameter must be # used instead of ``x``, ``y`` and ``direction``. @@ -139,7 +141,7 @@ # vector could be simply added to the 2d ``numpy`` array object # and passed using ``data`` parameter. -# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +# vector specifications structured as: [x_start, y_start, direction_degrees, length] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information @@ -188,7 +190,7 @@ direction=[[-25], [3]], ) -# vector specifications structured as: [x_start, y_start, direction_degrees, magnitude] +# vector specifications structured as: [x_start, y_start, direction_degrees, length] vector_2 = [-82, 40.5, 138, 3] vector_3 = [-71.2, 45, -115.7, 6] # Create a list of lists that include each vector information @@ -243,7 +245,7 @@ # ---------- # # When plotting circular vectors, there are 5 values that should be included in -# the list that is passed through np.array() in order to create a valid plot. +# the list that is passed through ``np.array()`` in order to create a valid plot. # The first two values in ``circular_vector_1`` represent the origin of the # circle that will be plotted. The next value is the radius which is represented # on the plot in centimeters. Finally, the last two values represent the degree @@ -276,8 +278,8 @@ # to the value of ct. This function is used to generate random data points for # ``radius`` and ``stopdir`` since these values are intended to be different in # each of the five vectors begin plotted. The second function is ``np.full`` -# which creates a numpy.ndarray. Finally, all of this data is congregated into -# a final numpy.ndarray called data using ``np.column_stack``. This is then +# which creates a ``numpy.ndarray``. Finally, all of this data is congregated into +# a final ``numpy.ndarray`` called data using ``np.column_stack``. This is then # passed to the plot function and the resulting figure is shown below. ct = 5 @@ -304,7 +306,7 @@ # When this is changed to inches, the size of the plot appears larger when the # projection units do not change. Below is an example of two circular vectors. # One is plotted using the default unit, and the second is plotted using inches. -# The difference in size of the two vectors provides good insignt into how this +# The difference in size of the two vectors provides good insight into how this # functionality works. circular_vector_1 = [0, 0, 5, 90, 270] @@ -337,12 +339,13 @@ # Plot Geographic Vectors # ---------- # Geographic graph using x and y values to set a start and an ending point. -# Use `fig.coast` to display the output of a coast. `x` and `y` are coordinates -# on a grid that we are using. `x` is Idaho and `y` is chicago in this example. +# Use ``fig.coast`` to plot a coast. ``x`` and ``y`` are coordinates +# on a grid that we are using. ``x`` is Idaho and ``y`` is Chicago in this example. # The geographical vector is going from Idaho to Chicago. To style geographic -# vectors, use `=` at the begining to refer it to geographic. `Fig.plot` is where -# you can style your vector. As you can see the vector is red and has the style -# of a geographic vector. +# vectors, use ``=`` at the begining of the ``style`` parameter. +# Other styling features such as arrowhead color and line thickness +# can be passed into +# ``pen`` and ``color``parameters fig = pygmt.Figure() fig.coast( @@ -427,8 +430,8 @@ fig.show() ################################################################################ -# This geographic vector is using the `Mercator` projection. For this we have -# `fig.coast` with the region, frame, land and projection type. Then for the vector +# This geographic vector is using the Mercator projection. For this we have +# ``fig.coast`` with the region, frame, land and projection type. Then for the vector # points we are starting at SA which is South Africa and going to four different # places. From cba945704352139bfe7f82c4e0045edd91c37e4a Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 26 Mar 2021 13:28:59 -0400 Subject: [PATCH 43/75] add . and other grammar fixes --- examples/tutorials/vectors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 2ac7d7a7b2e..dd000f27b1c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -30,7 +30,7 @@ # which is specified by the ``projection`` parameter. # The length of the vector also uses centimeters by default but # could be changed using :meth:`pygmt.config` -# (Check the next examples for unit changes) +# (Check the next examples for unit changes). # # Notice that the ``v`` in the ``style`` parameter stands for # vector; it distinguishes it from regular lines and allows for @@ -59,7 +59,7 @@ # Additionally, we changed the style of the vector to include a red # arrowhead and increased the thickness of the line. A list of different # styling attributes can be found in -# :doc:`Vector heads and tails ` +# :doc:`Vector heads and tails `. fig = pygmt.Figure() fig.plot( @@ -77,7 +77,7 @@ ######################################################################################## # The default unit of vector length is centimeters, -# however, this can be changed to inches or points. Note that, in GMT, +# however, this can be changed to inches or points. Note that, in PyGMT, # one point is defined as 1/72 inch. # # In this example, the graphed region is 10in X 4in, but @@ -117,7 +117,7 @@ # Each vector list contains the information structured as: # ``[x_start, y_start, direction_degrees, length]`` # -# If this approach is chosen, ``data`` parameter must be +# If this approach is chosen, the ``data`` parameter must be # used instead of ``x``, ``y`` and ``direction``. # Create a list of lists that include each vector information From 0a78355adf1ea7157e6bf3b7515ed240fea22f9a Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 26 Mar 2021 13:38:17 -0400 Subject: [PATCH 44/75] add grammar fixes --- examples/tutorials/vectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index dd000f27b1c..23f0106b69c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -165,7 +165,7 @@ ######################################################################################## # In this example, cartesian vectors are plotted over a Mercator # projection of the continental US. The x values represent the -# longitude and y values represent the latitude where the vector starts +# longitude and y values represent the latitude where the vector starts. # create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() @@ -249,7 +249,7 @@ # The first two values in ``circular_vector_1`` represent the origin of the # circle that will be plotted. The next value is the radius which is represented # on the plot in centimeters. Finally, the last two values represent the degree -# at which the plot will start and stop. In this example, the result show is the +# at which the plot will start and stop. In this example, the result shown is the # left half of a circle as the plot starts at 90 degrees and goes until 270. # It is important to note that when plotting circular vectors, the style value # should begin with an ``m``. From f9a7a9cf0e0e8812ed12cee02a1481ac0b1956a4 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:28:04 -0400 Subject: [PATCH 45/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 23f0106b69c..f0512dc0e21 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -1,6 +1,6 @@ """ Plot vectors -========== +============ Plotting vectors is handled by :meth:`pygmt.Figure.plot`. From 908b98349cea573d231b70be1960b04c7049923c Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:28:13 -0400 Subject: [PATCH 46/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index f0512dc0e21..ad0a0ca23ea 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -20,7 +20,7 @@ ######################################################################################## # Plot Caretesian Vectors -# ---------- +# ----------------------- # # Create a simple Cartesian vector using a starting point through # ``x``, ``y``, and ``direction`` parameters. The direction is specified From cf578fbdb00ee1fdf081cbe346a10958e360fbe6 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:28:38 -0400 Subject: [PATCH 47/75] Updated formatting of examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index ad0a0ca23ea..734c10be376 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -242,7 +242,7 @@ ######################################################################################## # Plot Circular Vectors -# ---------- +# --------------------- # # When plotting circular vectors, there are 5 values that should be included in # the list that is passed through ``np.array()`` in order to create a valid plot. From 1cb8a390e51c0ddcbed09d5bd5961b3f053be5f9 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:29:45 -0400 Subject: [PATCH 48/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 734c10be376..0fb0cf95c6a 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -337,7 +337,7 @@ ######################################################################################## # Plot Geographic Vectors -# ---------- +# ----------------------- # Geographic graph using x and y values to set a start and an ending point. # Use ``fig.coast`` to plot a coast. ``x`` and ``y`` are coordinates # on a grid that we are using. ``x`` is Idaho and ``y`` is Chicago in this example. From fd2e152b5b0ca2ef8b3b09450cfcc5a522c3bedc Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:30:10 -0400 Subject: [PATCH 49/75] Removed extra line after line 436 Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 0fb0cf95c6a..55f30849def 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -435,7 +435,6 @@ # points we are starting at SA which is South Africa and going to four different # places. - fig = pygmt.Figure() fig.coast( region=[-180, 180, -80, 80], From cbca2700edd45490212e0e577a33b0ce12d8de84 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Fri, 26 Mar 2021 18:24:02 -0400 Subject: [PATCH 50/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 55f30849def..3cd9fae40f5 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -56,8 +56,8 @@ # of all x and y coordinates will be passed. Similarly, the length of direction # list will increase accordingly. # -# Additionally, we changed the style of the vector to include a red -# arrowhead and increased the thickness of the line. A list of different +# Additionally, we change the style of the vector to include a red +# arrowhead and increase the thickness of the line. A list of different # styling attributes can be found in # :doc:`Vector heads and tails `. From 2f90190ef9f838420b6a7ecf3ce50d93cabae568 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Fri, 26 Mar 2021 18:54:56 -0400 Subject: [PATCH 51/75] reduce projection size --- examples/tutorials/vectors.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 23f0106b69c..ba0197e7cf8 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -80,7 +80,7 @@ # however, this can be changed to inches or points. Note that, in PyGMT, # one point is defined as 1/72 inch. # -# In this example, the graphed region is 10in X 4in, but +# In this example, the graphed region is 5in X 5in, but # the length of the first vector is still graphed in centimeters. # Using ``pygmt.config(PROJ_LENGTH_UNIT="i")``, the default unit # can be changed to inches in the second plotted vector. @@ -89,7 +89,7 @@ # Vector 1 with default unit as cm fig.plot( region=[0, 10, 0, 10], - projection="X10i/4i", + projection="X5i/5i", frame="a", x=2, y=8, @@ -171,7 +171,7 @@ fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], - projection="M15c", + projection="M10c", frame="ag", borders=1, area_thresh=4000, @@ -191,8 +191,8 @@ ) # vector specifications structured as: [x_start, y_start, direction_degrees, length] -vector_2 = [-82, 40.5, 138, 3] -vector_3 = [-71.2, 45, -115.7, 6] +vector_2 = [-82, 40.5, 138, 2.5] +vector_3 = [-71.2, 45, -115.7, 4] # Create a list of lists that include each vector information vectors = np.array([vector_2] + [vector_3]) @@ -214,7 +214,7 @@ fig = pygmt.Figure() fig.coast( region=[20, 50, 30, 45], - projection="T35/12c", + projection="T35/10c", frame=True, borders=1, area_thresh=4000, @@ -255,14 +255,14 @@ # should begin with an ``m``. # vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] -circular_vector_1 = [0, 0, 5, 90, 270] +circular_vector_1 = [0, 0, 2.5, 90, 270] data = np.array([circular_vector_1]) fig = pygmt.Figure() fig.plot( region=[-10, 10, -10, 10], - projection="X20c", + projection="X10c", frame="ag", data=data, style="m0.5c+ea", @@ -283,7 +283,7 @@ # passed to the plot function and the resulting figure is shown below. ct = 5 -radius = 5 - (0.5 * np.arange(0, ct)) +radius = 3 - (0.5 * np.arange(0, ct)) startdir = np.full(ct, 90) stopdir = 180 + (50 * np.arange(0, ct)) @@ -292,7 +292,7 @@ fig = pygmt.Figure() fig.plot( region=[-10, 10, -10, 10], - projection="X20c", + projection="X10c", frame="ag", data=data, style="m0.5c+ea", @@ -309,15 +309,15 @@ # The difference in size of the two vectors provides good insight into how this # functionality works. -circular_vector_1 = [0, 0, 5, 90, 270] -circular_vector_2 = [0, 0, 5, 90, 270] +circular_vector_1 = [6, 5, 2, 90, 270] +circular_vector_2 = [6, 5, 1, 90, 270] data_1 = np.array([circular_vector_1]) fig = pygmt.Figure() fig.plot( - region=[-15, 15, -15, 15], - projection="X30c", + region=[0, 10, 0, 10], + projection="X10c", frame="ag", data=data_1, style="m0.5c+ea", @@ -350,7 +350,7 @@ fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], - projection="M15c", + projection="M10c", frame=True, borders=1, area_thresh=4000, @@ -378,7 +378,7 @@ fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], - projection="M15c", + projection="M10c", frame=True, borders=1, area_thresh=4000, From b3426b6b59d89452b7b0cd69dd2a491795a6618b Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Sat, 27 Mar 2021 11:52:27 -0400 Subject: [PATCH 52/75] Remove backticks from numpy. Add angle description --- examples/tutorials/vectors.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index efeffe88c98..ad9ba9a2cda 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -24,7 +24,9 @@ # # Create a simple Cartesian vector using a starting point through # ``x``, ``y``, and ``direction`` parameters. The direction is specified -# by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]`` +# by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]``. +# The angle is measured in degrees and moves counter-clockwise from the +# horizontal. # # On the shown figure, the plot is projected on a 10cm X 10cm region, # which is specified by the ``projection`` parameter. @@ -35,7 +37,7 @@ # Notice that the ``v`` in the ``style`` parameter stands for # vector; it distinguishes it from regular lines and allows for # different customization. ``0c`` is used to specify the size -# of the arrowhead which explains why there is no arrow on either +# of the arrow head which explains why there is no arrow on either # side of the vector. fig = pygmt.Figure() @@ -57,7 +59,7 @@ # list will increase accordingly. # # Additionally, we change the style of the vector to include a red -# arrowhead and increase the thickness of the line. A list of different +# arrow head and increase the thickness of the line. A list of different # styling attributes can be found in # :doc:`Vector heads and tails `. @@ -113,7 +115,7 @@ ######################################################################################## # Vectors can also be plotted by including all the information # about a vector in a single list. However, this requires creating -# a list for all vectors and passing it into a ``numpy`` array object. +# a list for all vectors and passing it into a numpy array object. # Each vector list contains the information structured as: # ``[x_start, y_start, direction_degrees, length]`` # @@ -138,7 +140,7 @@ ######################################################################################## # Using the functionality mentioned in the previous example, # multiple vectors can be plotted at the same time. Another -# vector could be simply added to the 2d ``numpy`` array object +# vector could be simply added to the 2d numpy array object # and passed using ``data`` parameter. # vector specifications structured as: [x_start, y_start, direction_degrees, length] @@ -272,7 +274,7 @@ fig.show() ######################################################################################## -# When plotting multiple vectors there is a multitude of ``numpy`` functions +# When plotting multiple vectors there is a multitude of numpy functions # that can make this process easier. In the following example, three main numpy # functions are used. The first of which is ``np.arange`` which iterates from 0 # to the value of ct. This function is used to generate random data points for @@ -343,7 +345,7 @@ # on a grid that we are using. ``x`` is Idaho and ``y`` is Chicago in this example. # The geographical vector is going from Idaho to Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. -# Other styling features such as arrowhead color and line thickness +# Other styling features such as arrow head color and line thickness # can be passed into # ``pen`` and ``color``parameters From 562e95f8c729a153f4befa4b51a2d1e3752216a3 Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Sat, 27 Mar 2021 19:58:20 -0400 Subject: [PATCH 53/75] Apply suggestions from code review Co-authored-by: Dongdong Tian Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index ad9ba9a2cda..8c93203bd17 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -1,6 +1,6 @@ """ -Plot vectors -============ +Plotting vectors +================ Plotting vectors is handled by :meth:`pygmt.Figure.plot`. @@ -59,7 +59,7 @@ # list will increase accordingly. # # Additionally, we change the style of the vector to include a red -# arrow head and increase the thickness of the line. A list of different +# arrow head at the end (**+e**) of the vector and increase the thickness of the vector stem. A list of different # styling attributes can be found in # :doc:`Vector heads and tails `. @@ -147,7 +147,7 @@ vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information -vectors = np.array([vector_1] + [vector_2]) +vectors = np.array([vector_1, vector_2]) # vectors structure: # [[ 2. 3. 45. 4. ] # [ 7.5 8.3 -120.5 7.2]] @@ -196,7 +196,7 @@ vector_2 = [-82, 40.5, 138, 2.5] vector_3 = [-71.2, 45, -115.7, 4] # Create a list of lists that include each vector information -vectors = np.array([vector_2] + [vector_3]) +vectors = np.array([vector_2, vector_3]) fig.plot( data=vectors, From 0559e9e71431461f18e69346bb36d72a5dc8eca5 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 14:04:37 -0400 Subject: [PATCH 54/75] switch style and direction order --- examples/tutorials/vectors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 8c93203bd17..51879d72ff1 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -47,8 +47,8 @@ frame="ag", x=2, y=8, - direction=[[-45], [6]], style="v0c", + direction=[[-45], [6]], ) fig.show() @@ -70,8 +70,8 @@ frame="ag", x=[2, 4], y=[8, 1], - direction=[[-45, 23], [6, 3]], style="v0.6c+e", + direction=[[-45, 23], [6, 3]], pen="2p", color="red3", ) @@ -92,11 +92,11 @@ fig.plot( region=[0, 10, 0, 10], projection="X5i/5i", - frame="a", + frame="ag", x=2, y=8, - direction=[[0], [3]], style="v1c+e", + direction=[[0], [3]], pen="2p", color="red3", ) @@ -234,9 +234,9 @@ x=x, y=y, style="v0.4c+ea", + direction=[direction, length], pen="0.6p", color="red3", - direction=[direction, length], ) From 5a43914199c452033f4ab09bfa2e50b78f36b1a8 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 14:07:03 -0400 Subject: [PATCH 55/75] switch area_thress and shorelines --- examples/tutorials/vectors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 51879d72ff1..e6dbb317590 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -176,8 +176,8 @@ projection="M10c", frame="ag", borders=1, - area_thresh=4000, shorelines="0.25p,black", + area_thresh=4000, land="grey", water="lightblue", ) @@ -219,8 +219,8 @@ projection="T35/10c", frame=True, borders=1, - area_thresh=4000, shorelines="0.25p,black", + area_thresh=4000, land="lightbrown", water="lightblue", ) @@ -355,8 +355,8 @@ projection="M10c", frame=True, borders=1, - area_thresh=4000, shorelines="0.25p,black", + area_thresh=4000, ) point_1 = [-114.7420, 44.0682] point_2 = [-87.6298, 41.8781] @@ -383,8 +383,8 @@ projection="M10c", frame=True, borders=1, - area_thresh=4000, shorelines="0.25p,black", + area_thresh=4000, ) # Plot geographic vectors using coordinates. ME = [-69.4455, 45.2538] From 87db34ecc2ce1e6e680731f5563335afb117d5e8 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 14:39:52 -0400 Subject: [PATCH 56/75] fix first paragraph --- examples/tutorials/vectors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index e6dbb317590..f3118a184eb 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -23,13 +23,13 @@ # ----------------------- # # Create a simple Cartesian vector using a starting point through -# ``x``, ``y``, and ``direction`` parameters. The direction is specified +# ``x``, ``y``, and ``direction`` parameters. +# On the shown figure, the plot is projected on a 10cm X 10cm region, +# which is specified by the ``projection`` parameter. +# The direction is specified # by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]``. # The angle is measured in degrees and moves counter-clockwise from the # horizontal. -# -# On the shown figure, the plot is projected on a 10cm X 10cm region, -# which is specified by the ``projection`` parameter. # The length of the vector also uses centimeters by default but # could be changed using :meth:`pygmt.config` # (Check the next examples for unit changes). @@ -233,7 +233,7 @@ fig.plot( x=x, y=y, - style="v0.4c+ea", + style="v0.4c+ea+bc", direction=[direction, length], pen="0.6p", color="red3", From e9cf9cd6953c6d2a2ff06da25f1eab2522ca7734 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 20:45:12 -0400 Subject: [PATCH 57/75] Fix plot, remove unnecessary numpy --- examples/tutorials/vectors.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index f3118a184eb..9a78d33b050 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -257,13 +257,13 @@ # should begin with an ``m``. # vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] -circular_vector_1 = [0, 0, 2.5, 90, 270] +circular_vector_1 = [0, 0, 2, 90, 270] -data = np.array([circular_vector_1]) +data = [circular_vector_1] fig = pygmt.Figure() fig.plot( - region=[-10, 10, -10, 10], + region=[-5, 5, -5, 5], projection="X10c", frame="ag", data=data, @@ -293,7 +293,7 @@ fig = pygmt.Figure() fig.plot( - region=[-10, 10, -10, 10], + region=[-5, 5, -5, 5], projection="X10c", frame="ag", data=data, @@ -314,7 +314,7 @@ circular_vector_1 = [6, 5, 2, 90, 270] circular_vector_2 = [6, 5, 1, 90, 270] -data_1 = np.array([circular_vector_1]) +data_1 = [circular_vector_1] fig = pygmt.Figure() fig.plot( @@ -327,7 +327,7 @@ color="red3", ) -data_2 = np.array([circular_vector_2]) +data_2 = [circular_vector_2] with pygmt.config(PROJ_LENGTH_UNIT="i"): fig.plot( data=data_2, From 1e9aea094408285170fe3c55f6711c5e4d4112b4 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 20:59:03 -0400 Subject: [PATCH 58/75] Revise wording around numpy --- examples/tutorials/vectors.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 9a78d33b050..12165ca5788 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -115,7 +115,7 @@ ######################################################################################## # Vectors can also be plotted by including all the information # about a vector in a single list. However, this requires creating -# a list for all vectors and passing it into a numpy array object. +# a 2D list or numpy array containing all vectors. # Each vector list contains the information structured as: # ``[x_start, y_start, direction_degrees, length]`` # @@ -123,7 +123,7 @@ # used instead of ``x``, ``y`` and ``direction``. # Create a list of lists that include each vector information -vectors = np.array([[2, 3, 45, 4]]) # vectors structure: [[ 2 3 45 4]] +vectors = [[2, 3, 45, 4]] # vectors structure: [[ 2 3 45 4]] fig = pygmt.Figure() fig.plot( @@ -140,7 +140,8 @@ ######################################################################################## # Using the functionality mentioned in the previous example, # multiple vectors can be plotted at the same time. Another -# vector could be simply added to the 2d numpy array object +# vector could be simply added to the 2D list or numpy +# array object # and passed using ``data`` parameter. # vector specifications structured as: [x_start, y_start, direction_degrees, length] @@ -196,7 +197,7 @@ vector_2 = [-82, 40.5, 138, 2.5] vector_3 = [-71.2, 45, -115.7, 4] # Create a list of lists that include each vector information -vectors = np.array([vector_2, vector_3]) +vectors = [vector_2, vector_3] fig.plot( data=vectors, @@ -247,7 +248,8 @@ # --------------------- # # When plotting circular vectors, there are 5 values that should be included in -# the list that is passed through ``np.array()`` in order to create a valid plot. +# a 2D list or ``np.array()`` object in order to create +# a valid plot. The vectors must be passed to the ``data`` parameter. # The first two values in ``circular_vector_1`` represent the origin of the # circle that will be plotted. The next value is the radius which is represented # on the plot in centimeters. Finally, the last two values represent the degree @@ -271,6 +273,18 @@ pen="2p", color="red3", ) + +# Another example using np.array() +circular_vector_2 = [0, 0, 4, -90, 90] + +data = np.array([circular_vector_2]) + +fig.plot( + data=data, + style="m0.5c+ea", + pen="2p", + color="red3", +) fig.show() ######################################################################################## From 79a01bc72013225878a4d5702e7e4cdd82ca016a Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Mon, 29 Mar 2021 21:11:46 -0400 Subject: [PATCH 59/75] Add styling description --- examples/tutorials/vectors.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 12165ca5788..43ad76e2a10 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -169,6 +169,17 @@ # In this example, cartesian vectors are plotted over a Mercator # projection of the continental US. The x values represent the # longitude and y values represent the latitude where the vector starts. +# +# This example also shows some of the styles a vector supports. +# ``+ba`` specifies that the begining point of the vector ``+b`` +# should take the shape of a circle ``c``. Similarly, the end +# point of the vector ``+e`` should have an arrow shape ``a`` +# (to draw a plain arrow, use ``A`` instead). Lastly, the ``+a`` +# specifies the angle of the vector head apex (30 degrees in +# this example). +# +# More styling options can be found here +# :doc:`Vector heads and tails `. # create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() @@ -183,7 +194,7 @@ water="lightblue", ) -style = "v0.6c+bc+ea+a30" +style = "v0.4c+bc+ea+a30" fig.plot( x=-110, y=40, From 31ca200cb0a912a209002d9c6267d17b54766829 Mon Sep 17 00:00:00 2001 From: Claire <46755872+cklima616@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:55:56 -0400 Subject: [PATCH 60/75] Update examples/tutorials/vectors.py Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 43ad76e2a10..07ca3f7b306 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -19,8 +19,8 @@ import pygmt ######################################################################################## -# Plot Caretesian Vectors -# ----------------------- +# Plot Cartesian Vectors +# ---------------------- # # Create a simple Cartesian vector using a starting point through # ``x``, ``y``, and ``direction`` parameters. From 6dd5a25b55d92cba24db8e3629fc594779d6bff1 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:57:28 -0400 Subject: [PATCH 61/75] Update examples/tutorials/vectors.py Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 07ca3f7b306..db9b93bdcb1 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -287,7 +287,6 @@ # Another example using np.array() circular_vector_2 = [0, 0, 4, -90, 90] - data = np.array([circular_vector_2]) fig.plot( From cdf4cfc957bd4af5ce6d3bd9d9aac9fd65963777 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:58:27 -0400 Subject: [PATCH 62/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index db9b93bdcb1..b1088d6517c 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -259,7 +259,7 @@ # --------------------- # # When plotting circular vectors, there are 5 values that should be included in -# a 2D list or ``np.array()`` object in order to create +# a 2D list or numpy array object in order to create # a valid plot. The vectors must be passed to the ``data`` parameter. # The first two values in ``circular_vector_1`` represent the origin of the # circle that will be plotted. The next value is the radius which is represented From 1bb8301bb4adb87acb7fe7372cfe70de09580fe1 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:59:45 -0400 Subject: [PATCH 63/75] Update examples/tutorials/vectors.py Co-authored-by: Dongdong Tian --- examples/tutorials/vectors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index b1088d6517c..c2acc598050 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -328,7 +328,7 @@ fig.show() ######################################################################################## -# Much like when plotting regular vectors, the default unit used is centimeters. +# Much like when plotting Cartesian vectors, the default unit used is centimeters. # When this is changed to inches, the size of the plot appears larger when the # projection units do not change. Below is an example of two circular vectors. # One is plotted using the default unit, and the second is plotted using inches. From f479599ff18e9b3b05082ea4a00513453aca2055 Mon Sep 17 00:00:00 2001 From: Nathandloria <42869173+Nathandloria@users.noreply.github.com> Date: Wed, 31 Mar 2021 14:00:46 -0400 Subject: [PATCH 64/75] Update examples/tutorials/vectors.py Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index c2acc598050..684d8a3a83e 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -312,7 +312,6 @@ radius = 3 - (0.5 * np.arange(0, ct)) startdir = np.full(ct, 90) stopdir = 180 + (50 * np.arange(0, ct)) - data = np.column_stack([np.full(ct, 0), np.full(ct, 0), radius, startdir, stopdir]) fig = pygmt.Figure() From e10a7ee145a3b20ff561eb9065d9aed96470624f Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 31 Mar 2021 14:46:23 -0400 Subject: [PATCH 65/75] Made changes to circular examples per @core-man reccomendations --- examples/tutorials/vectors.py | 53 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 684d8a3a83e..fa876839210 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -256,20 +256,20 @@ ######################################################################################## # Plot Circular Vectors -# --------------------- +# ---------- # -# When plotting circular vectors, there are 5 values that should be included in -# a 2D list or numpy array object in order to create -# a valid plot. The vectors must be passed to the ``data`` parameter. -# The first two values in ``circular_vector_1`` represent the origin of the -# circle that will be plotted. The next value is the radius which is represented -# on the plot in centimeters. Finally, the last two values represent the degree -# at which the plot will start and stop. In this example, the result shown is the -# left half of a circle as the plot starts at 90 degrees and goes until 270. -# It is important to note that when plotting circular vectors, the style value -# should begin with an ``m``. - -# vector specifications structured as: [x_start, y_start, radius, degree_start, degree_stop] +# When plotting circular vectors, all of the information for a single vector is +# to be stored in a list. Each circular vector list is structured as: [x_start, +# y_start, radius, degree_start, degree_stop]. The first two values in +# ``circular_vector_1`` represent the origin of the circle that will be plotted. +# The next value is the radius which is represented on the plot in centimeters. +# +# The last two values in the vector list represent the degree at which the plot +# will start and stop. These values are measured counter-clockwise from the horizontal +# axis. In this example, the result show is the left half of a circle as the +# plot starts at 90 degrees and goes until 270. Notice that the ``m`` in the +# ``style`` parameter stands for circular vectors. + circular_vector_1 = [0, 0, 2, 90, 270] data = [circular_vector_1] @@ -298,21 +298,18 @@ fig.show() ######################################################################################## -# When plotting multiple vectors there is a multitude of numpy functions -# that can make this process easier. In the following example, three main numpy -# functions are used. The first of which is ``np.arange`` which iterates from 0 -# to the value of ct. This function is used to generate random data points for -# ``radius`` and ``stopdir`` since these values are intended to be different in -# each of the five vectors begin plotted. The second function is ``np.full`` -# which creates a ``numpy.ndarray``. Finally, all of this data is congregated into -# a final ``numpy.ndarray`` called data using ``np.column_stack``. This is then -# passed to the plot function and the resulting figure is shown below. - -ct = 5 -radius = 3 - (0.5 * np.arange(0, ct)) -startdir = np.full(ct, 90) -stopdir = 180 + (50 * np.arange(0, ct)) -data = np.column_stack([np.full(ct, 0), np.full(ct, 0), radius, startdir, stopdir]) +# When plotting multiple circular vectors, a two dimensional array or numpy array +# object should be passed as the data parameter. In this example, the numpy column +# stack function is used to generate this two dimensional array. Other numpy objects +# are used to generate random values for the ``degree_stop`` and ``radius`` parameters +# discussed in the previous example. This is the reason in which each vector has +# a different appearance on the projection. + +vector_num = 5 +radius = 3 - (0.5 * np.arange(0, vector_num)) +startdir = np.full(vector_num, 90) +stopdir = 180 + (50 * np.arange(0, vector_num)) +data = np.column_stack([np.full(vector_num, 0), np.full(vector_num, 0), radius, startdir, stopdir]) fig = pygmt.Figure() fig.plot( From 5a61cdf0ee0048e96e02a22e9119cbc4b66377c2 Mon Sep 17 00:00:00 2001 From: Nathan Loria Date: Wed, 31 Mar 2021 14:50:15 -0400 Subject: [PATCH 66/75] re-formatted with black --- examples/tutorials/vectors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index fa876839210..7346ccaf131 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -309,7 +309,9 @@ radius = 3 - (0.5 * np.arange(0, vector_num)) startdir = np.full(vector_num, 90) stopdir = 180 + (50 * np.arange(0, vector_num)) -data = np.column_stack([np.full(vector_num, 0), np.full(vector_num, 0), radius, startdir, stopdir]) +data = np.column_stack( + [np.full(vector_num, 0), np.full(vector_num, 0), radius, startdir, stopdir] +) fig = pygmt.Figure() fig.plot( From c6eadbe31f7320957e654595251fb3261867e311 Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 31 Mar 2021 16:16:52 -0400 Subject: [PATCH 67/75] MAde changes to comment section around lines 169 --- examples/tutorials/vectors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 7346ccaf131..0207261144d 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -117,7 +117,7 @@ # about a vector in a single list. However, this requires creating # a 2D list or numpy array containing all vectors. # Each vector list contains the information structured as: -# ``[x_start, y_start, direction_degrees, length]`` +# ``[x_start, y_start, direction_degrees, length]``. # # If this approach is chosen, the ``data`` parameter must be # used instead of ``x``, ``y`` and ``direction``. @@ -171,10 +171,10 @@ # longitude and y values represent the latitude where the vector starts. # # This example also shows some of the styles a vector supports. -# ``+ba`` specifies that the begining point of the vector ``+b`` +# The beginning point **+bc** of the vector (**+b**) # should take the shape of a circle ``c``. Similarly, the end -# point of the vector ``+e`` should have an arrow shape ``a`` -# (to draw a plain arrow, use ``A`` instead). Lastly, the ``+a`` +# point of the vector **+e** should have an arrow shape **a** +# (to draw a plain arrow, use ``A`` instead). Lastly, the **+a** # specifies the angle of the vector head apex (30 degrees in # this example). # From 462986279b240ef0aba95cc382b9039cad163b5e Mon Sep 17 00:00:00 2001 From: Megan Munzek Date: Wed, 31 Mar 2021 16:30:33 -0400 Subject: [PATCH 68/75] Fixed wording in paragraphs --- examples/tutorials/vectors.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 0207261144d..3271996b328 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -172,9 +172,9 @@ # # This example also shows some of the styles a vector supports. # The beginning point **+bc** of the vector (**+b**) -# should take the shape of a circle ``c``. Similarly, the end +# should take the shape of a circle **c**. Similarly, the end # point of the vector **+e** should have an arrow shape **a** -# (to draw a plain arrow, use ``A`` instead). Lastly, the **+a** +# (to draw a plain arrow, use **A** instead). Lastly, the **+a** # specifies the angle of the vector head apex (30 degrees in # this example). # @@ -221,7 +221,7 @@ ######################################################################################## # Another example of plotting cartesian vectors over a coast plot. This time -# a Transverse Mercator projection is used. Additionally, ``numpy.linespace`` +# a Transverse Mercator projection is used. Additionally, :func:'numpy.linespace` # is used to create 5 vectors with equal stops. # create a plot with coast, Mercator projection (M) over the continental US @@ -362,10 +362,9 @@ ######################################################################################## # Plot Geographic Vectors # ----------------------- -# Geographic graph using x and y values to set a start and an ending point. -# Use ``fig.coast`` to plot a coast. ``x`` and ``y`` are coordinates -# on a grid that we are using. ``x`` is Idaho and ``y`` is Chicago in this example. -# The geographical vector is going from Idaho to Chicago. To style geographic +# Geographic graph using `point_1` and `point_2` to set a start and an ending point. +# This graph uses ``fig.coast`` to plot a coast. ``point_1`` and ``point_2`` are coordinates +# on a grid that we are using. The geographical vector is going from Idaho to Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. # Other styling features such as arrow head color and line thickness # can be passed into @@ -393,10 +392,9 @@ fig.show() ######################################################################################## -# This Geographic Vector is using the `fig.coast` of the region of the United States. # The plotting of the geographic vectors when using latitude and longitude # are labeled by having the coordinates displayed. -# Then an array is created so the vectors follow the one vector before it. You +# An array is created so the vectors follow the one vector before it. You # can diplay this array any way you want. fig = pygmt.Figure() From 196d6d047c5d60624349bd602218822eef1f7582 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 21:29:54 -0400 Subject: [PATCH 69/75] Add general fixes and clarifications --- examples/tutorials/vectors.py | 46 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 3271996b328..213d3aa5385 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -144,14 +144,12 @@ # array object # and passed using ``data`` parameter. -# vector specifications structured as: [x_start, y_start, direction_degrees, length] +# Vector specifications structured as: [x_start, y_start, direction_degrees, length] vector_1 = [2, 3, 45, 4] vector_2 = [7.5, 8.3, -120.5, 7.2] # Create a list of lists that include each vector information -vectors = np.array([vector_1, vector_2]) -# vectors structure: -# [[ 2. 3. 45. 4. ] -# [ 7.5 8.3 -120.5 7.2]] +vectors = [vector_1, vector_2] +# Vectors structure: [[2, 3, 45, 4], [7.5, 8.3, -120.5, 7.2]] fig = pygmt.Figure() fig.plot( @@ -171,17 +169,17 @@ # longitude and y values represent the latitude where the vector starts. # # This example also shows some of the styles a vector supports. -# The beginning point **+bc** of the vector (**+b**) -# should take the shape of a circle **c**. Similarly, the end -# point of the vector **+e** should have an arrow shape **a** -# (to draw a plain arrow, use **A** instead). Lastly, the **+a** +# The beginning point of the vector (**+b**) +# should take the shape of a circle (**c**). Similarly, the end +# point of the vector (**+e**) should have an arrow shape (**a**) +# (to draw a plain arrow, use (**A**) instead). Lastly, the (**+a**) # specifies the angle of the vector head apex (30 degrees in # this example). # # More styling options can be found here # :doc:`Vector heads and tails `. -# create a plot with coast, Mercator projection (M) over the continental US +# Create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], @@ -330,13 +328,12 @@ # When this is changed to inches, the size of the plot appears larger when the # projection units do not change. Below is an example of two circular vectors. # One is plotted using the default unit, and the second is plotted using inches. -# The difference in size of the two vectors provides good insight into how this -# functionality works. +# Despite using the same list to plot the vectors, a different measurement unit +# causes one to be larger than the other. -circular_vector_1 = [6, 5, 2, 90, 270] -circular_vector_2 = [6, 5, 1, 90, 270] +circular_vector = [6, 5, 1, 90, 270] -data_1 = [circular_vector_1] +data_1 = [circular_vector] fig = pygmt.Figure() fig.plot( @@ -349,7 +346,7 @@ color="red3", ) -data_2 = [circular_vector_2] +data_2 = [circular_vector] with pygmt.config(PROJ_LENGTH_UNIT="i"): fig.plot( data=data_2, @@ -362,11 +359,13 @@ ######################################################################################## # Plot Geographic Vectors # ----------------------- -# Geographic graph using `point_1` and `point_2` to set a start and an ending point. -# This graph uses ``fig.coast`` to plot a coast. ``point_1`` and ``point_2`` are coordinates -# on a grid that we are using. The geographical vector is going from Idaho to Chicago. To style geographic +# On this map, +# ``point_1`` and ``point_2`` are coordinate pairs used to set the +# start and end points of the geographic vector. +# The geographical vector is going from Idaho to +# Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. -# Other styling features such as arrow head color and line thickness +# Other styling features such as arrow head color and stem thickness # can be passed into # ``pen`` and ``color``parameters @@ -452,10 +451,9 @@ fig.show() ################################################################################ -# This geographic vector is using the Mercator projection. For this we have -# ``fig.coast`` with the region, frame, land and projection type. Then for the vector -# points we are starting at SA which is South Africa and going to four different -# places. +# This example plots vectors over a Mercator projection. The starting points are +# located at SA which is South Africa and going to four different +# locations. fig = pygmt.Figure() fig.coast( From c30015a8ef53b7047f2f33e5b039b87e8094f5ea Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 21:52:45 -0400 Subject: [PATCH 70/75] Add fixes, restructure order --- examples/tutorials/vectors.py | 67 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 213d3aa5385..1f218887cbd 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -59,7 +59,8 @@ # list will increase accordingly. # # Additionally, we change the style of the vector to include a red -# arrow head at the end (**+e**) of the vector and increase the thickness of the vector stem. A list of different +# arrow head at the end (**+e**) of the vector and increase the +# thickness (``pen="2p"``) of the vector stem. A list of different # styling attributes can be found in # :doc:`Vector heads and tails `. @@ -123,7 +124,7 @@ # used instead of ``x``, ``y`` and ``direction``. # Create a list of lists that include each vector information -vectors = [[2, 3, 45, 4]] # vectors structure: [[ 2 3 45 4]] +vectors = [[2, 3, 45, 4]] fig = pygmt.Figure() fig.plot( @@ -141,8 +142,7 @@ # Using the functionality mentioned in the previous example, # multiple vectors can be plotted at the same time. Another # vector could be simply added to the 2D list or numpy -# array object -# and passed using ``data`` parameter. +# array object and passed using ``data`` parameter. # Vector specifications structured as: [x_start, y_start, direction_degrees, length] vector_1 = [2, 3, 45, 4] @@ -192,14 +192,15 @@ water="lightblue", ) +# Plot a vector using the x, y, direction parameters. style = "v0.4c+bc+ea+a30" fig.plot( x=-110, y=40, style=style, + direction=[[-25], [3]], pen="1p", color="red3", - direction=[[-25], [3]], ) # vector specifications structured as: [x_start, y_start, direction_degrees, length] @@ -208,13 +209,13 @@ # Create a list of lists that include each vector information vectors = [vector_2, vector_3] +# Plot vectors using the data parameter. fig.plot( data=vectors, style=style, pen="1p", color="yellow", ) - fig.show() ######################################################################################## @@ -222,6 +223,11 @@ # a Transverse Mercator projection is used. Additionally, :func:'numpy.linespace` # is used to create 5 vectors with equal stops. +x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] +y = np.linspace(39, 39, 5) # y values = [39. 39. 39. 39.] +direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] +length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] + # create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() fig.coast( @@ -235,11 +241,6 @@ water="lightblue", ) -x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] -y = np.linspace(39, 39, 5) # y values = [39. 39. 39. 39.] -direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] -length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] - fig.plot( x=x, y=y, @@ -365,9 +366,12 @@ # The geographical vector is going from Idaho to # Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. -# Other styling features such as arrow head color and stem thickness -# can be passed into -# ``pen`` and ``color``parameters +# Other styling features such as vector stem thickness and head color +# can be passed into ``pen`` and ``color``parameters + +point_1 = [-114.7420, 44.0682] +point_2 = [-87.6298, 41.8781] +data = np.array([point_1 + point_2]) fig = pygmt.Figure() fig.coast( @@ -378,9 +382,6 @@ shorelines="0.25p,black", area_thresh=4000, ) -point_1 = [-114.7420, 44.0682] -point_2 = [-87.6298, 41.8781] -data = np.array([point_1 + point_2]) fig.plot( data=data, @@ -396,6 +397,15 @@ # An array is created so the vectors follow the one vector before it. You # can diplay this array any way you want. + +# Coordinate pairs for all the locations used. +ME = [-69.4455, 45.2538] +CHI = [-87.6298, 41.8781] +SEA = [-122.3321, 47.6062] +NO = [-90.0715, 29.9511] +KC = [-94.5786, 39.0997] +CA = [-119.4179, 36.7783] + fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], @@ -405,13 +415,7 @@ shorelines="0.25p,black", area_thresh=4000, ) -# Plot geographic vectors using coordinates. -ME = [-69.4455, 45.2538] -CHI = [-87.6298, 41.8781] -SEA = [-122.3321, 47.6062] -NO = [-90.0715, 29.9511] -KC = [-94.5786, 39.0997] -CA = [-119.4179, 36.7783] + # Add array to piece together the vectors. data = np.array([ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA]) fig.plot( @@ -455,20 +459,21 @@ # located at SA which is South Africa and going to four different # locations. +SA = [22.9375, -30.5595] +EUR = [15.2551, 54.5260] +ME = [-69.4455, 45.2538] +AS = [100.6197, 34.0479] +NM = [-105.8701, 34.5199] +data = np.array([SA + EUR, SA + ME, SA + AS, SA + NM]) + fig = pygmt.Figure() fig.coast( region=[-180, 180, -80, 80], + projection="M0/0/12c", frame="afg", land="lightbrown", water="lightblue", - projection="M0/0/12c", ) -SA = [22.9375, -30.5595] -EUR = [15.2551, 54.5260] -ME = [-69.4455, 45.2538] -AS = [100.6197, 34.0479] -NM = [-105.8701, 34.5199] -data = np.array([SA + EUR, SA + ME, SA + AS, SA + NM]) fig.plot( data=data, From 5f97054ddb3620b5feacf68939b4baf9590a1274 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 21:56:09 -0400 Subject: [PATCH 71/75] Remove doc link and unneeded example --- examples/tutorials/vectors.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 1f218887cbd..b224b544176 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -175,9 +175,6 @@ # (to draw a plain arrow, use (**A**) instead). Lastly, the (**+a**) # specifies the angle of the vector head apex (30 degrees in # this example). -# -# More styling options can be found here -# :doc:`Vector heads and tails `. # Create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() @@ -426,34 +423,6 @@ ) fig.show() -################################################################################# -# This is a polyconic projection of geographic vectors. This projection -# is set to poly. The MC, ME, WA variables are connected to Mexico City (MC) -# Maine (ME), and Washington (WA). Each variable has a coordinate corrensponding -# that place. - -fig = pygmt.Figure() -fig.coast( - shorelines="1/0.5p", - region=[-180, -20, 0, 90], - projection="Poly/12c", - land="gray", - borders="1/thick,black", - frame="afg10", -) -MC = [-99.1332, 19.4326] -ME = [-69.4455, 45.2538] -WA = [-122.5210, 47.6249] -data = np.array([MC + ME, ME + WA]) - -fig.plot( - data=data, - style="=0.5c+ea+s", - pen="2p", - color="red3", -) -fig.show() - ################################################################################ # This example plots vectors over a Mercator projection. The starting points are # located at SA which is South Africa and going to four different From 92563cb11da72ac28626903576c9782df46a50da Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 21:59:25 -0400 Subject: [PATCH 72/75] Add minor typo and comment fixes --- examples/tutorials/vectors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index b224b544176..d52859051f9 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -101,7 +101,7 @@ pen="2p", color="red3", ) -# Vector 2 after changing default unit to in +# Vector 2 after changing default unit to inch with pygmt.config(PROJ_LENGTH_UNIT="i"): fig.plot( x=2, @@ -217,7 +217,7 @@ ######################################################################################## # Another example of plotting cartesian vectors over a coast plot. This time -# a Transverse Mercator projection is used. Additionally, :func:'numpy.linespace` +# a Transverse Mercator projection is used. Additionally, :func:'numpy.linspace` # is used to create 5 vectors with equal stops. x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] @@ -225,7 +225,7 @@ direction = np.linspace(-90, -90, 5) # direction values = [-90. -90. -90. -90.] length = np.linspace(1.5, 1.5, 5) # length values = [1.5 1.5 1.5 1.5] -# create a plot with coast, Mercator projection (M) over the continental US +# Create a plot with coast, Mercator projection (M) over the continental US fig = pygmt.Figure() fig.coast( region=[20, 50, 30, 45], @@ -255,8 +255,8 @@ # ---------- # # When plotting circular vectors, all of the information for a single vector is -# to be stored in a list. Each circular vector list is structured as: [x_start, -# y_start, radius, degree_start, degree_stop]. The first two values in +# to be stored in a list. Each circular vector list is structured as: +# ``[x_start, y_start, radius, degree_start, degree_stop]``. The first two values in # ``circular_vector_1`` represent the origin of the circle that will be plotted. # The next value is the radius which is represented on the plot in centimeters. # From 541fed01df9d87f7edb1ff4bfba9ed4b3aef8215 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 22:22:23 -0400 Subject: [PATCH 73/75] Add clarification to example, explain +s --- examples/tutorials/vectors.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index d52859051f9..1fbeff2351a 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -364,7 +364,10 @@ # Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. # Other styling features such as vector stem thickness and head color -# can be passed into ``pen`` and ``color``parameters +# can be passed into ``pen`` and ``color``parameters. +# +# Note that the (**+s**) is added to use a startpoint and an endpoint +# to represent the vector instead of input angle and length. point_1 = [-114.7420, 44.0682] point_2 = [-87.6298, 41.8781] @@ -389,11 +392,13 @@ fig.show() ######################################################################################## -# The plotting of the geographic vectors when using latitude and longitude -# are labeled by having the coordinates displayed. -# An array is created so the vectors follow the one vector before it. You -# can diplay this array any way you want. - +# Using the same technique shown in the previous example, +# multiple vectors can be plotted in a chain where the endpoint +# of one is the starting point of another. This can be done +# by adding the coordinate lists together to create this structure: +# ``[[start_latitude, start_longitude, end_latitude, end_longitude]]``. +# Each list within the 2D list contains the start and end information +# for each vector. # Coordinate pairs for all the locations used. ME = [-69.4455, 45.2538] @@ -403,6 +408,9 @@ KC = [-94.5786, 39.0997] CA = [-119.4179, 36.7783] +# Add array to piece together the vectors. +data = [ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA] + fig = pygmt.Figure() fig.coast( region=[-127, -64, 24, 53], @@ -413,8 +421,6 @@ area_thresh=4000, ) -# Add array to piece together the vectors. -data = np.array([ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA]) fig.plot( data=data, style="=0.5c+ea+s", From 38f68a690296bf427ff02e49b46632e2b56c6df1 Mon Sep 17 00:00:00 2001 From: noorbuchi Date: Thu, 1 Apr 2021 22:55:20 -0400 Subject: [PATCH 74/75] Add minor typo fixes --- examples/tutorials/vectors.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 1fbeff2351a..7864cc4a560 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -172,7 +172,7 @@ # The beginning point of the vector (**+b**) # should take the shape of a circle (**c**). Similarly, the end # point of the vector (**+e**) should have an arrow shape (**a**) -# (to draw a plain arrow, use (**A**) instead). Lastly, the (**+a**) +# (to draw a plain arrow, use **A** instead). Lastly, the **+a** # specifies the angle of the vector head apex (30 degrees in # this example). @@ -217,7 +217,7 @@ ######################################################################################## # Another example of plotting cartesian vectors over a coast plot. This time -# a Transverse Mercator projection is used. Additionally, :func:'numpy.linspace` +# a Transverse Mercator projection is used. Additionally, :func:`numpy.linspace` # is used to create 5 vectors with equal stops. x = np.linspace(36, 42, 5) # x values = [36. 37.5 39. 40.5 42. ] @@ -257,7 +257,7 @@ # When plotting circular vectors, all of the information for a single vector is # to be stored in a list. Each circular vector list is structured as: # ``[x_start, y_start, radius, degree_start, degree_stop]``. The first two values in -# ``circular_vector_1`` represent the origin of the circle that will be plotted. +# the vector list represent the origin of the circle that will be plotted. # The next value is the radius which is represented on the plot in centimeters. # # The last two values in the vector list represent the degree at which the plot @@ -295,7 +295,7 @@ ######################################################################################## # When plotting multiple circular vectors, a two dimensional array or numpy array -# object should be passed as the data parameter. In this example, the numpy column +# object should be passed as the ``data``` parameter. In this example, the numpy column # stack function is used to generate this two dimensional array. Other numpy objects # are used to generate random values for the ``degree_stop`` and ``radius`` parameters # discussed in the previous example. This is the reason in which each vector has @@ -364,9 +364,9 @@ # Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. # Other styling features such as vector stem thickness and head color -# can be passed into ``pen`` and ``color``parameters. +# can be passed into ``pen`` and ``color`` parameters. # -# Note that the (**+s**) is added to use a startpoint and an endpoint +# Note that the **+s** is added to use a startpoint and an endpoint # to represent the vector instead of input angle and length. point_1 = [-114.7420, 44.0682] From 41168160588c0ef6fad95ab9f9ad69b85a61445d Mon Sep 17 00:00:00 2001 From: Noor Buchi <55197145+noorbuchi@users.noreply.github.com> Date: Fri, 2 Apr 2021 10:28:46 -0400 Subject: [PATCH 75/75] Apply suggestions from code review Co-authored-by: Yao Jiayuan --- examples/tutorials/vectors.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/examples/tutorials/vectors.py b/examples/tutorials/vectors.py index 7864cc4a560..589407bb83e 100644 --- a/examples/tutorials/vectors.py +++ b/examples/tutorials/vectors.py @@ -30,7 +30,7 @@ # by a list of two 1d arrays structured as ``[[angle_in_degrees], [length]]``. # The angle is measured in degrees and moves counter-clockwise from the # horizontal. -# The length of the vector also uses centimeters by default but +# The length of the vector uses centimeters by default but # could be changed using :meth:`pygmt.config` # (Check the next examples for unit changes). # @@ -189,7 +189,7 @@ water="lightblue", ) -# Plot a vector using the x, y, direction parameters. +# Plot a vector using the x, y, direction parameters style = "v0.4c+bc+ea+a30" fig.plot( x=-110, @@ -247,7 +247,6 @@ color="red3", ) - fig.show() ######################################################################################## @@ -266,11 +265,10 @@ # plot starts at 90 degrees and goes until 270. Notice that the ``m`` in the # ``style`` parameter stands for circular vectors. -circular_vector_1 = [0, 0, 2, 90, 270] +fig = pygmt.Figure() +circular_vector_1 = [0, 0, 2, 90, 270] data = [circular_vector_1] - -fig = pygmt.Figure() fig.plot( region=[-5, 5, -5, 5], projection="X10c", @@ -295,10 +293,11 @@ ######################################################################################## # When plotting multiple circular vectors, a two dimensional array or numpy array -# object should be passed as the ``data``` parameter. In this example, the numpy column -# stack function is used to generate this two dimensional array. Other numpy objects -# are used to generate random values for the ``degree_stop`` and ``radius`` parameters -# discussed in the previous example. This is the reason in which each vector has +# object should be passed as the ``data`` parameter. In this example, :func:`numpy.column_stack` +# is used to generate this two dimensional array. Other numpy objects are used to +# generate linear values for the ``radius`` parameter and random values for +# the ``degree_stop`` parameter discussed in the previous example. This is +# the reason in which each vector has # a different appearance on the projection. vector_num = 5 @@ -331,23 +330,20 @@ circular_vector = [6, 5, 1, 90, 270] -data_1 = [circular_vector] - fig = pygmt.Figure() fig.plot( region=[0, 10, 0, 10], projection="X10c", frame="ag", - data=data_1, + data=[circular_vector], style="m0.5c+ea", pen="2p", color="red3", ) -data_2 = [circular_vector] with pygmt.config(PROJ_LENGTH_UNIT="i"): fig.plot( - data=data_2, + data=[circular_vector], style="m0.5c+ea", pen="2p", color="red3", @@ -364,7 +360,7 @@ # Chicago. To style geographic # vectors, use ``=`` at the begining of the ``style`` parameter. # Other styling features such as vector stem thickness and head color -# can be passed into ``pen`` and ``color`` parameters. +# can be passed into the ``pen`` and ``color`` parameters. # # Note that the **+s** is added to use a startpoint and an endpoint # to represent the vector instead of input angle and length. @@ -382,7 +378,6 @@ shorelines="0.25p,black", area_thresh=4000, ) - fig.plot( data=data, style="=0.5c+ea+s", @@ -400,7 +395,7 @@ # Each list within the 2D list contains the start and end information # for each vector. -# Coordinate pairs for all the locations used. +# Coordinate pairs for all the locations used ME = [-69.4455, 45.2538] CHI = [-87.6298, 41.8781] SEA = [-122.3321, 47.6062] @@ -408,7 +403,7 @@ KC = [-94.5786, 39.0997] CA = [-119.4179, 36.7783] -# Add array to piece together the vectors. +# Add array to piece together the vectors data = [ME + CHI, CHI + SEA, SEA + KC, KC + NO, NO + CA] fig = pygmt.Figure() @@ -420,7 +415,6 @@ shorelines="0.25p,black", area_thresh=4000, ) - fig.plot( data=data, style="=0.5c+ea+s", @@ -449,7 +443,6 @@ land="lightbrown", water="lightblue", ) - fig.plot( data=data, style="=0.5c+ea+s",