From d166b6591cfca29807e1e1b5593c11cc072f611b Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Mon, 7 Jun 2021 21:37:03 +0800 Subject: [PATCH 1/9] Update rectangle in the multi-parameter symbols --- .../gallery/symbols/multi_parameter_symbols.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index a8d804ba9ad..f62f389a2ca 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -25,7 +25,7 @@ import pygmt fig = pygmt.Figure() -fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) +fig.basemap(region=[0, 6.5, 0, 2], projection="x3c", frame=True) # ELLIPSE data = [[0.5, 1, 45, 3, 1]] @@ -36,15 +36,25 @@ fig.plot(data=data, style="j", color="red3", pen="2p,black") # RECTANGLE -data = [[3, 1, 4, 1.5]] +data = [[3, 0.5, 4, 1.5]] fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") +# RECTANGLE +# width/height are given via the style parameter +data = [[3, 1.5]] +fig.plot(data=data, style="r4/1.5", color="dodgerblue", pen="2p,black") + # ROUNDED RECTANGLE data = [[4.5, 1, 1.25, 4, 0.5]] fig.plot(data=data, style="R", color="seagreen", pen="2p,black") +# ROUNDED RECTANGLE +# width/height/radius are given via the style parameter +data = [[5.0, 1]] +fig.plot(data=data, style="R1.25/4/0.5", color="seagreen", pen="2p,black") + # PIE WEDGE -data = [[5.5, 1, 2.5, 45, 330]] +data = [[6.0, 1, 2.5, 45, 330]] fig.plot(data=data, style="w", color="lightgray", pen="2p,black") fig.show() From 9c0faf0c1d0777df5a7a8e45a7340b33015b8894 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Tue, 8 Jun 2021 08:37:04 +0800 Subject: [PATCH 2/9] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/symbols/multi_parameter_symbols.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index f62f389a2ca..3cb82a95392 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -41,8 +41,7 @@ # RECTANGLE # width/height are given via the style parameter -data = [[3, 1.5]] -fig.plot(data=data, style="r4/1.5", color="dodgerblue", pen="2p,black") +fig.plot(x=3, y=1.5, style="r4/1.5", color="dodgerblue", pen="2p,black") # ROUNDED RECTANGLE data = [[4.5, 1, 1.25, 4, 0.5]] @@ -50,8 +49,7 @@ # ROUNDED RECTANGLE # width/height/radius are given via the style parameter -data = [[5.0, 1]] -fig.plot(data=data, style="R1.25/4/0.5", color="seagreen", pen="2p,black") +fig.plot(x=5.0, y=1.0, style="R1.25/4/0.5", color="seagreen", pen="2p,black") # PIE WEDGE data = [[6.0, 1, 2.5, 45, 330]] From 227b8e1a5003910766a5d82ee9e9bcb6f555f8bd Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Tue, 8 Jun 2021 12:12:36 +0800 Subject: [PATCH 3/9] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/symbols/multi_parameter_symbols.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 3cb82a95392..9e79251a2ba 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -35,19 +35,19 @@ data = [[1.5, 1, 120, 5, 0.5]] fig.plot(data=data, style="j", color="red3", pen="2p,black") -# RECTANGLE +# RECTANGLE 1 data = [[3, 0.5, 4, 1.5]] fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") -# RECTANGLE +# RECTANGLE 2 # width/height are given via the style parameter fig.plot(x=3, y=1.5, style="r4/1.5", color="dodgerblue", pen="2p,black") -# ROUNDED RECTANGLE +# ROUNDED RECTANGLE 1 data = [[4.5, 1, 1.25, 4, 0.5]] fig.plot(data=data, style="R", color="seagreen", pen="2p,black") -# ROUNDED RECTANGLE +# ROUNDED RECTANGLE 2 # width/height/radius are given via the style parameter fig.plot(x=5.0, y=1.0, style="R1.25/4/0.5", color="seagreen", pen="2p,black") From c45d5ea33b3dba616bcddbb3990ec387aaad3484 Mon Sep 17 00:00:00 2001 From: core-man Date: Wed, 9 Jun 2021 15:08:23 +0800 Subject: [PATCH 4/9] Add new syntax for all the multi-parameter symbols --- .../symbols/multi_parameter_symbols.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 9e79251a2ba..37cc5aa3c72 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -4,10 +4,12 @@ The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by passing the corresponding shortcuts listed below to the ``style`` -parameter. Additionally, we must define the required parameters in a 2d list or +parameter. Additionally, we can define the required parameters in a 2d list or numpy array (``[[parameters]]`` for a single symbol or ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an appropriately formatted input file and pass it to ``data``. +Alternatively, the required parameters can also be set after those shortcuts +via the ``style`` parameter. The following symbols are available: @@ -27,14 +29,22 @@ fig = pygmt.Figure() fig.basemap(region=[0, 6.5, 0, 2], projection="x3c", frame=True) -# ELLIPSE -data = [[0.5, 1, 45, 3, 1]] +# ELLIPSE 1 +data = [[0.5, 0.5, 45, 3, 1]] fig.plot(data=data, style="e", color="orange", pen="2p,black") -# ROTATED RECTANGLE -data = [[1.5, 1, 120, 5, 0.5]] +# ELLIPSE 2 +# direction/major_axis/minor_axis are given via the style parameter +fig.plot(x=0.5, y=1.5, style="e45/3/1", color="orange", pen="2p,black") + +# ROTATED RECTANGLE 1 +data = [[1.4, 1, 120, 5, 0.5]] fig.plot(data=data, style="j", color="red3", pen="2p,black") +# ROTATED RECTANGLE 2 +# direction/width/height are given via the style parameter +fig.plot(x=1.7, y=1, style="j120/5/0.5", color="red3", pen="2p,black") + # RECTANGLE 1 data = [[3, 0.5, 4, 1.5]] fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") @@ -51,8 +61,12 @@ # width/height/radius are given via the style parameter fig.plot(x=5.0, y=1.0, style="R1.25/4/0.5", color="seagreen", pen="2p,black") -# PIE WEDGE -data = [[6.0, 1, 2.5, 45, 330]] +# PIE WEDGE 1 +data = [[6.0, 0.5, 2.5, 45, 330]] fig.plot(data=data, style="w", color="lightgray", pen="2p,black") +# PIE WEDGE 2 +# radius/startdir/stopdir are given via the style parameter +fig.plot(x=6.0, y=1.5, style="w2.5/45/330", color="lightgray", pen="2p,black") + fig.show() From 2f7db26a86e711079ad1ac8ddcafad9c32c17127 Mon Sep 17 00:00:00 2001 From: core-man Date: Sat, 19 Jun 2021 22:10:38 +0800 Subject: [PATCH 5/9] Split the example into two figures --- .../symbols/multi_parameter_symbols.py | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 37cc5aa3c72..7c2a870d648 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -26,47 +26,43 @@ import pygmt +# The 1st simple way: plot multi-parameter symbols using the same symbol style +# x and y can be scalar (this example) or 1D lists fig = pygmt.Figure() -fig.basemap(region=[0, 6.5, 0, 2], projection="x3c", frame=True) +fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) + +# Ellipse +fig.plot(x=0.5, y=1, style="e45/3/1", color="orange", pen="2p,black") +# Rotated rectangle +fig.plot(x=1.5, y=1, style="j120/5/0.5", color="red3", pen="2p,black") +# Rectangle +fig.plot(x=3, y=1, style="r4/1.5", color="dodgerblue", pen="2p,black") +# Rounded rectangle +fig.plot(x=4.5, y=1, style="R1.25/4/0.5", color="seagreen", pen="2p,black") +# Pie wedge +fig.plot(x=5.5, y=1, style="w2.5/45/330", color="lightgray", pen="2p,black") -# ELLIPSE 1 -data = [[0.5, 0.5, 45, 3, 1]] -fig.plot(data=data, style="e", color="orange", pen="2p,black") +fig.show() -# ELLIPSE 2 -# direction/major_axis/minor_axis are given via the style parameter -fig.plot(x=0.5, y=1.5, style="e45/3/1", color="orange", pen="2p,black") +# The 2nd way: plot multi-parameter symbols using varying symbol styles +# The data parameter can be 2D array +fig = pygmt.Figure() +fig.basemap(region=[0, 6, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"]) -# ROTATED RECTANGLE 1 -data = [[1.4, 1, 120, 5, 0.5]] +# Ellipse +data = [[0.5, 1, 45, 3, 1], [0.5, 3, 135, 2, 1]] +fig.plot(data=data, style="e", color="orange", pen="2p,black") +# Rotated rectangle +data = [[1.5, 1, 120, 5, 0.5], [1.5, 3, 50, 3, 0.5]] fig.plot(data=data, style="j", color="red3", pen="2p,black") - -# ROTATED RECTANGLE 2 -# direction/width/height are given via the style parameter -fig.plot(x=1.7, y=1, style="j120/5/0.5", color="red3", pen="2p,black") - -# RECTANGLE 1 -data = [[3, 0.5, 4, 1.5]] +# Rectangle +data = [[3, 1, 4, 1.5], [3, 3, 3, 1.5]] fig.plot(data=data, style="r", color="dodgerblue", pen="2p,black") - -# RECTANGLE 2 -# width/height are given via the style parameter -fig.plot(x=3, y=1.5, style="r4/1.5", color="dodgerblue", pen="2p,black") - -# ROUNDED RECTANGLE 1 -data = [[4.5, 1, 1.25, 4, 0.5]] +# Rounded rectangle +data = [[4.5, 1, 1.25, 4, 0.5], [4.5, 3, 1.25, 2.0, 0.2]] fig.plot(data=data, style="R", color="seagreen", pen="2p,black") - -# ROUNDED RECTANGLE 2 -# width/height/radius are given via the style parameter -fig.plot(x=5.0, y=1.0, style="R1.25/4/0.5", color="seagreen", pen="2p,black") - -# PIE WEDGE 1 -data = [[6.0, 0.5, 2.5, 45, 330]] +# Pie wedge +data = [[5.5, 1, 2.5, 45, 330], [5.5, 3, 1.5, 60, 300]] fig.plot(data=data, style="w", color="lightgray", pen="2p,black") -# PIE WEDGE 2 -# radius/startdir/stopdir are given via the style parameter -fig.plot(x=6.0, y=1.5, style="w2.5/45/330", color="lightgray", pen="2p,black") - fig.show() From fcea6c5c99f6a3e9444365bcbc05461347781d77 Mon Sep 17 00:00:00 2001 From: core-man Date: Sat, 19 Jun 2021 22:32:53 +0800 Subject: [PATCH 6/9] Update comments --- .../gallery/symbols/multi_parameter_symbols.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 7c2a870d648..9ad9b44be4e 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -3,13 +3,14 @@ ------------------------- The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter -symbols by passing the corresponding shortcuts listed below to the ``style`` -parameter. Additionally, we can define the required parameters in a 2d list or -numpy array (``[[parameters]]`` for a single symbol or +symbols by passing the corresponding shortcuts (**e**, **j**, **r**, **R**, +**w**) to the ``style`` parameter. Additionally, We need to define locations +(lon, lat) via the ``x`` and ``y`` parameters (scalar for a single symbol or 1d +list for servel ones) and two or three symbol parameters after those shortcuts +via the ``style`` parameter. Alternately, those values can also be defined in a +2d list or numpy array (``[[parameters]]`` for a single symbol or ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an appropriately formatted input file and pass it to ``data``. -Alternatively, the required parameters can also be set after those shortcuts -via the ``style`` parameter. The following symbols are available: @@ -27,7 +28,7 @@ import pygmt # The 1st simple way: plot multi-parameter symbols using the same symbol style -# x and y can be scalar (this example) or 1D lists +# x and y can be scalar (this example) or 1d lists fig = pygmt.Figure() fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) @@ -45,7 +46,7 @@ fig.show() # The 2nd way: plot multi-parameter symbols using varying symbol styles -# The data parameter can be 2D array +# The data parameter can be 2d array fig = pygmt.Figure() fig.basemap(region=[0, 6, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"]) From 23e97cbe40902554611b65e9c59e107edad57201 Mon Sep 17 00:00:00 2001 From: core-man Date: Sat, 19 Jun 2021 22:37:32 +0800 Subject: [PATCH 7/9] Add gallery thumbnail number --- examples/gallery/symbols/multi_parameter_symbols.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 9ad9b44be4e..500f340ccde 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -25,6 +25,8 @@ **w** but expect geographic azimuths and distances. """ +# sphinx_gallery_thumbnail_number = 2 + import pygmt # The 1st simple way: plot multi-parameter symbols using the same symbol style From 739de0dff124d378346cf5b3be32ec4cbf7c2d39 Mon Sep 17 00:00:00 2001 From: core-man Date: Sat, 19 Jun 2021 23:41:45 +0800 Subject: [PATCH 8/9] Update sytle --- .../symbols/multi_parameter_symbols.py | 60 ++++++++++++------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 500f340ccde..5b8154d9520 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -4,33 +4,38 @@ The :meth:`pygmt.Figure.plot` method can plot individual multi-parameter symbols by passing the corresponding shortcuts (**e**, **j**, **r**, **R**, -**w**) to the ``style`` parameter. Additionally, We need to define locations -(lon, lat) via the ``x`` and ``y`` parameters (scalar for a single symbol or 1d -list for servel ones) and two or three symbol parameters after those shortcuts -via the ``style`` parameter. Alternately, those values can also be defined in a -2d list or numpy array (``[[parameters]]`` for a single symbol or -``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or use an -appropriately formatted input file and pass it to ``data``. +**w**) to the ``style`` parameter: -The following symbols are available: +- **e**: ellipse +- **j**: rotated rectangle +- **r**: rectangle +- **R**: rounded rectangle +- **w**: pie wedge -- **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]`` -- **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]`` -- **r**: rectangle, ``[[lon, lat, width, height]]`` -- **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]`` -- **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two - arguments are directions given in degrees counter-clockwise from horizontal - -Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and -**w** but expect geographic azimuths and distances. """ # sphinx_gallery_thumbnail_number = 2 import pygmt -# The 1st simple way: plot multi-parameter symbols using the same symbol style -# x and y can be scalar (this example) or 1d lists +######################################################################################## +# We can plot multi-parameter symbols using the same symbol style. We need to +# define locations (lon, lat) via the ``x`` and ``y`` parameters (scalar for +# a single symbol or 1d list for servel ones) and two or three symbol +# parameters after those shortcuts via the ``style`` parameter. +# +# The symbol parameters in the ``style`` parameter are defined as: +# +# - **e**: ellipse, ``direction/major_axis/minor_axis`` +# - **j**: rotated rectangle, ``direction/width/height`` +# - **r**: rectangle, ``width/height`` +# - **R**: rounded rectangle, ``width/height/radius`` +# - **w**: pie wedge, ``radius/startdir/stopdir``, the last two arguments are +# directions given in degrees counter-clockwise from horizontal +# +# Upper-case versions **E**, **J**, and **W** are similar to **e**, **j** and +# **w** but expect geographic azimuths and distances. + fig = pygmt.Figure() fig.basemap(region=[0, 6, 0, 2], projection="x3c", frame=True) @@ -47,8 +52,21 @@ fig.show() -# The 2nd way: plot multi-parameter symbols using varying symbol styles -# The data parameter can be 2d array +######################################################################################## +# We can also plot symbols with varying parameters via defining those values in +# a 2d list or numpy array (``[[parameters]]`` for a single symbol or +# ``[[parameters_1],[parameters_2],[parameters_i]]`` for several ones) or using +# an appropriately formatted input file and passing it to ``data``. +# +# The symbol parameters in the 2d list or numpy array are defined as: +# +# - **e**: ellipse, ``[[lon, lat, direction, major_axis, minor_axis]]`` +# - **j**: rotated rectangle, ``[[lon, lat, direction, width, height]]`` +# - **r**: rectangle, ``[[lon, lat, width, height]]`` +# - **R**: rounded rectangle, ``[[lon, lat, width, height, radius]]`` +# - **w**: pie wedge, ``[[lon, lat, radius, startdir, stopdir]]``, the last two +# arguments are directions given in degrees counter-clockwise from horizontal + fig = pygmt.Figure() fig.basemap(region=[0, 6, 0, 4], projection="x3c", frame=["xa1f0.2", "ya0.5f0.1"]) From f0b336b516f732a21d0bae9f73147e6cad55bde7 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Sun, 20 Jun 2021 02:11:05 +0800 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Meghan Jones --- examples/gallery/symbols/multi_parameter_symbols.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/symbols/multi_parameter_symbols.py b/examples/gallery/symbols/multi_parameter_symbols.py index 5b8154d9520..85ec53be115 100644 --- a/examples/gallery/symbols/multi_parameter_symbols.py +++ b/examples/gallery/symbols/multi_parameter_symbols.py @@ -21,10 +21,10 @@ ######################################################################################## # We can plot multi-parameter symbols using the same symbol style. We need to # define locations (lon, lat) via the ``x`` and ``y`` parameters (scalar for -# a single symbol or 1d list for servel ones) and two or three symbol +# a single symbol or 1d list for several ones) and two or three symbol # parameters after those shortcuts via the ``style`` parameter. # -# The symbol parameters in the ``style`` parameter are defined as: +# The multi-parameter symbols in the ``style`` parameter are defined as: # # - **e**: ellipse, ``direction/major_axis/minor_axis`` # - **j**: rotated rectangle, ``direction/width/height``