From bfdbb35c460ef63ef76905e33dbd76207e65fba4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 6 Nov 2024 11:25:26 +0100 Subject: [PATCH 01/19] Add basci tutorial for polygons - code --- examples/tutorials/basics/polygons.py | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 examples/tutorials/basics/polygons.py diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py new file mode 100644 index 00000000000..49bd71e2dca --- /dev/null +++ b/examples/tutorials/basics/polygons.py @@ -0,0 +1,84 @@ +""" +Plotting polygon +================ + +Plotting plotting is handled by :meth:`pygmt.Figure.plot`. +refere to choropleth map for geopandas polygon geometry. +""" + +# %% +import pygmt + +# %% +# Plot polygons +# ------------- + +x_list = [-2, 1, 3, 0, -4, -2] +y_list = [-3, -1, 1, 3, 2, -3] + +# %% +# text + +fig = pygmt.Figure() +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list) + +fig.show() + +# %% +# text + +fig = pygmt.Figure() +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, pen="2p,darkred,dashed") + +fig.show() + +# %% +# text +fig = pygmt.Figure() +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, fill="orange", pen="2p,darkred,dashed") + +fig.show() + + +# %% +# Close polygons +# -------------- + +x_list = [-2, 1, 3, 0, -4] +y_list = [-3, -1, 1, 3, 2] + +# %% +# text +fig = pygmt.Figure() +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, pen=True) + +fig.shift_origin(xshift="+w1c") +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, pen=True, close=True) + +fig.show() + +# %% +# text +fig = pygmt.Figure() +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, pen=True) + +fig.shift_origin(xshift="+w1c") +fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) + +fig.plot(x=x_list, y=y_list, pen=True, fill="orange") + +fig.show() + +# sphinx_gallery_thumbnail_number = 3 From 2f2d2f70edba4508877d456a9c9669aba56172a3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 6 Nov 2024 19:00:28 +0100 Subject: [PATCH 02/19] Add documentation --- examples/tutorials/basics/polygons.py | 52 +++++++++++++++++++-------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 49bd71e2dca..f18185ebdb9 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -1,23 +1,33 @@ """ -Plotting polygon -================ +Plotting polygons +================= -Plotting plotting is handled by :meth:`pygmt.Figure.plot`. -refere to choropleth map for geopandas polygon geometry. +Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. + +This tutorial focuses on input data given via lists or NumPy arrays. For +plotting GeoPandas polygon geometry, e.g. to create a chorophlet map, see +the gallery example https://www.pygmt.org/dev/gallery/maps/choropleth_map.html. """ # %% +import numpy as np import pygmt # %% # Plot polygons # ------------- +# +# Set up sample data points as lists for the x and y values. x_list = [-2, 1, 3, 0, -4, -2] y_list = [-3, -1, 1, 3, 2, -3] # %% -# text +# Create a Cartesian plot via the :meth:`pygmt.Figure.basemap` method. +# Pass lists to the ``x`` and ``y`` parameters of the :meth:`pygmt.Figure.plot` +# method. Without further adjustments, lines are drawn between the data points. +# By default, the lines are 0.25-points thick, black, and solid. In this example, +# the data points are chosen to make the lines form a polygon. fig = pygmt.Figure() fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) @@ -27,20 +37,27 @@ fig.show() # %% -# text +# The ``pen`` parameter can be used to adjust the lines or outline of the polygon. +# The argument passed to ``pen`` is one string with the comma-separated optional +# values *width*,\ *color*,\ *style*. fig = pygmt.Figure() fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +# Use a 2-points thick, darkred, dashed outline fig.plot(x=x_list, y=y_list, pen="2p,darkred,dashed") fig.show() # %% -# text +# Use the ``fill`` parameter to fill the polygon with a color or pattern. +# For the patterns avilable in GMT see the Technical Reference at +# https://www.pygmt.org/dev/techref/patterns.html. + fig = pygmt.Figure() fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +# Fill the polygon with color "orange" fig.plot(x=x_list, y=y_list, fill="orange", pen="2p,darkred,dashed") fig.show() @@ -49,35 +66,40 @@ # %% # Close polygons # -------------- +# +# Set up sample data points as NumPy array for the x and y values. Now, +# the data points do not form a polygon. -x_list = [-2, 1, 3, 0, -4] -y_list = [-3, -1, 1, 3, 2] +x_array = np.array([-2, 1, 3, 0, -4]) +y_array = np.array([-3, -1, 1, 3, 2]) # %% -# text +# The ``close`` parameter can be used to force the polygon to be closed. + fig = pygmt.Figure() fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) -fig.plot(x=x_list, y=y_list, pen=True) +fig.plot(x=x_array, y=y_array, pen=True) fig.shift_origin(xshift="+w1c") fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) -fig.plot(x=x_list, y=y_list, pen=True, close=True) +fig.plot(x=x_array, y=y_array, pen=True, close=True) fig.show() # %% -# text +# When using the ``fill`` parameter, the polygon is automatically closed. + fig = pygmt.Figure() fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) -fig.plot(x=x_list, y=y_list, pen=True) +fig.plot(x=x_array, y=y_array, pen=True) fig.shift_origin(xshift="+w1c") fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) -fig.plot(x=x_list, y=y_list, pen=True, fill="orange") +fig.plot(x=x_array, y=y_array, pen=True, fill="orange") fig.show() From 704891916005193369618f915823f89864c895c9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 10 Nov 2024 14:34:04 +0100 Subject: [PATCH 03/19] Add link to gallery example --- examples/tutorials/basics/polygons.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index f18185ebdb9..e0f4f3eed66 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -5,8 +5,8 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. This tutorial focuses on input data given via lists or NumPy arrays. For -plotting GeoPandas polygon geometry, e.g. to create a chorophlet map, see -the gallery example https://www.pygmt.org/dev/gallery/maps/choropleth_map.html. +plotting GeoPandas polygon geometry, e.g. to create a chorophlet map, see the +gallery example :doc:`Choropleth map `. """ # %% From 7a8932d7ab5f3243d9734ce8be43fe5862c453c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 10 Nov 2024 17:23:35 +0100 Subject: [PATCH 04/19] Correct "xshift" argument Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index e0f4f3eed66..3e27c0c7542 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -81,7 +81,7 @@ fig.plot(x=x_array, y=y_array, pen=True) -fig.shift_origin(xshift="+w1c") +fig.shift_origin(xshift="w+1c") fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True, close=True) @@ -96,7 +96,7 @@ fig.plot(x=x_array, y=y_array, pen=True) -fig.shift_origin(xshift="+w1c") +fig.shift_origin(xshift="w+1c") fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True, fill="orange") From cf8ee7fac0bccddff043c5180a13ec8fd7f49e8d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 10 Nov 2024 17:28:12 +0100 Subject: [PATCH 05/19] Write 'region' argument as long list --- examples/tutorials/basics/polygons.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 3e27c0c7542..bf18de80a0e 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -30,7 +30,7 @@ # the data points are chosen to make the lines form a polygon. fig = pygmt.Figure() -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x_list, y=y_list) @@ -42,7 +42,7 @@ # values *width*,\ *color*,\ *style*. fig = pygmt.Figure() -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) # Use a 2-points thick, darkred, dashed outline fig.plot(x=x_list, y=y_list, pen="2p,darkred,dashed") @@ -55,7 +55,7 @@ # https://www.pygmt.org/dev/techref/patterns.html. fig = pygmt.Figure() -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) # Fill the polygon with color "orange" fig.plot(x=x_list, y=y_list, fill="orange", pen="2p,darkred,dashed") @@ -77,12 +77,12 @@ # The ``close`` parameter can be used to force the polygon to be closed. fig = pygmt.Figure() -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True) fig.shift_origin(xshift="w+1c") -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True, close=True) @@ -92,12 +92,12 @@ # When using the ``fill`` parameter, the polygon is automatically closed. fig = pygmt.Figure() -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True) fig.shift_origin(xshift="w+1c") -fig.basemap(region=[-5, 5] * 2, projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x_array, y=y_array, pen=True, fill="orange") From bd71d3e835ed6a9d731e1c748261f94186bee952 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 10 Nov 2024 17:41:12 +0100 Subject: [PATCH 06/19] Use only NumPy arrays --- examples/tutorials/basics/polygons.py | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index bf18de80a0e..e3b27d4c4ac 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -4,9 +4,10 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. -This tutorial focuses on input data given via lists or NumPy arrays. For -plotting GeoPandas polygon geometry, e.g. to create a chorophlet map, see the -gallery example :doc:`Choropleth map `. +This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, +array-like objects are supported. For plotting a GeoPandas GeoDataFrame with +polygon geometrie, e.g. to create a chorophlet map, see the gallery example +:doc:`Choropleth map `. """ # %% @@ -17,14 +18,14 @@ # Plot polygons # ------------- # -# Set up sample data points as lists for the x and y values. +# Set up sample data points as NumPy arrays for the x and y values. -x_list = [-2, 1, 3, 0, -4, -2] -y_list = [-3, -1, 1, 3, 2, -3] +x = np.array([-2, 1, 3, 0, -4, -2]) +y = np.array([-3, -1, 1, 3, 2, -3]) # %% # Create a Cartesian plot via the :meth:`pygmt.Figure.basemap` method. -# Pass lists to the ``x`` and ``y`` parameters of the :meth:`pygmt.Figure.plot` +# Pass arrays to the ``x`` and ``y`` parameters of the :meth:`pygmt.Figure.plot` # method. Without further adjustments, lines are drawn between the data points. # By default, the lines are 0.25-points thick, black, and solid. In this example, # the data points are chosen to make the lines form a polygon. @@ -32,7 +33,7 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) -fig.plot(x=x_list, y=y_list) +fig.plot(x=x, y=y) fig.show() @@ -45,7 +46,7 @@ fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) # Use a 2-points thick, darkred, dashed outline -fig.plot(x=x_list, y=y_list, pen="2p,darkred,dashed") +fig.plot(x=x, y=y, pen="2p,darkred,dashed") fig.show() @@ -58,7 +59,7 @@ fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) # Fill the polygon with color "orange" -fig.plot(x=x_list, y=y_list, fill="orange", pen="2p,darkred,dashed") +fig.plot(x=x, y=y, fill="orange", pen="2p,darkred,dashed") fig.show() @@ -70,8 +71,8 @@ # Set up sample data points as NumPy array for the x and y values. Now, # the data points do not form a polygon. -x_array = np.array([-2, 1, 3, 0, -4]) -y_array = np.array([-3, -1, 1, 3, 2]) +x = np.array([-2, 1, 3, 0, -4]) +y = np.array([-3, -1, 1, 3, 2]) # %% # The ``close`` parameter can be used to force the polygon to be closed. @@ -79,12 +80,12 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) -fig.plot(x=x_array, y=y_array, pen=True) +fig.plot(x=x, y=y, pen=True) fig.shift_origin(xshift="w+1c") fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) -fig.plot(x=x_array, y=y_array, pen=True, close=True) +fig.plot(x=x, y=y, pen=True, close=True) fig.show() @@ -94,12 +95,12 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) -fig.plot(x=x_array, y=y_array, pen=True) +fig.plot(x=x, y=y, pen=True) fig.shift_origin(xshift="w+1c") fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) -fig.plot(x=x_array, y=y_array, pen=True, fill="orange") +fig.plot(x=x, y=y, pen=True, fill="orange") fig.show() From 2e5a7e287846cded6aa1331e40f4fabb6c90670c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 10 Nov 2024 17:48:34 +0100 Subject: [PATCH 07/19] Fix typos --- examples/tutorials/basics/polygons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index e3b27d4c4ac..24ed9c8cc38 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -6,7 +6,7 @@ This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, array-like objects are supported. For plotting a GeoPandas GeoDataFrame with -polygon geometrie, e.g. to create a chorophlet map, see the gallery example +polygon geometries, e.g. to create a choropleth map, see the gallery example :doc:`Choropleth map `. """ From a299405b0335f239620566051da6bce80ac6e0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:37:27 +0100 Subject: [PATCH 08/19] Correct link Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 24ed9c8cc38..63816a74f2e 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -7,7 +7,7 @@ This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, array-like objects are supported. For plotting a GeoPandas GeoDataFrame with polygon geometries, e.g. to create a choropleth map, see the gallery example -:doc:`Choropleth map `. +:doc:`Choropleth map `. """ # %% From ce35b66a2ec89067801b10a78b862b280db60ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:37:44 +0100 Subject: [PATCH 09/19] Add highlighting Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 63816a74f2e..e1f57352f3b 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -5,7 +5,7 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, -array-like objects are supported. For plotting a GeoPandas GeoDataFrame with +array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` object with polygon geometries, e.g. to create a choropleth map, see the gallery example :doc:`Choropleth map `. """ From 994b93ebb191af7b6e7c236045160518fb169fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:38:55 +0100 Subject: [PATCH 10/19] Shorten formulation and add link Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index e1f57352f3b..34f83f12d5c 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -51,9 +51,7 @@ fig.show() # %% -# Use the ``fill`` parameter to fill the polygon with a color or pattern. -# For the patterns avilable in GMT see the Technical Reference at -# https://www.pygmt.org/dev/techref/patterns.html. +# Use the ``fill`` parameter to fill the polygon with a color or :doc:`pattern `. fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) From fef82cf1d6b503f6ba3d86662d2f9eac49b4212d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 11 Nov 2024 08:41:50 +0100 Subject: [PATCH 11/19] Adjust line length --- examples/tutorials/basics/polygons.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 34f83f12d5c..8fb3ffb1368 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -5,9 +5,9 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, -array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` object with -polygon geometries, e.g. to create a choropleth map, see the gallery example -:doc:`Choropleth map `. +array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` +object with polygon geometries, e.g. to create a choropleth map, see the gallery +example :doc:`Choropleth map `. """ # %% @@ -51,7 +51,8 @@ fig.show() # %% -# Use the ``fill`` parameter to fill the polygon with a color or :doc:`pattern `. +# Use the ``fill`` parameter to fill the polygon with a color or +# :doc:`pattern `. fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) From 7dea3312d137d828403daa9033ae283b48d17a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 18 Nov 2024 07:23:58 +0100 Subject: [PATCH 12/19] Rewrap to 88 chars Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 8fb3ffb1368..e88f5627105 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -5,9 +5,9 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, -array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` -object with polygon geometries, e.g. to create a choropleth map, see the gallery -example :doc:`Choropleth map `. +array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` object +with polygon geometries, e.g. to create a choropleth map, see the gallery example +:doc:`Choropleth map `. """ # %% @@ -24,11 +24,11 @@ y = np.array([-3, -1, 1, 3, 2, -3]) # %% -# Create a Cartesian plot via the :meth:`pygmt.Figure.basemap` method. -# Pass arrays to the ``x`` and ``y`` parameters of the :meth:`pygmt.Figure.plot` -# method. Without further adjustments, lines are drawn between the data points. -# By default, the lines are 0.25-points thick, black, and solid. In this example, -# the data points are chosen to make the lines form a polygon. +# Create a Cartesian plot via the :meth:`pygmt.Figure.basemap` method. Pass arrays to +# the ``x`` and ``y`` parameters of the :meth:`pygmt.Figure.plot` method. Without +# further adjustments, lines are drawn between the data points. By default, the lines +# are 0.25-points thick, black, and solid. In this example, the data points are chosen +# to make the lines form a polygon. fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) From 70db43a0ba0af2a72e1a810db912b23ac6fc726c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:50:52 +0100 Subject: [PATCH 13/19] Remove blank lines Co-authored-by: Dongdong Tian --- examples/tutorials/basics/polygons.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index e88f5627105..e6d9e0c298f 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -32,9 +32,7 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) - fig.plot(x=x, y=y) - fig.show() # %% @@ -44,10 +42,8 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) - # Use a 2-points thick, darkred, dashed outline fig.plot(x=x, y=y, pen="2p,darkred,dashed") - fig.show() # %% From 28a37e58d0173751ebafa6e05c109d497f7fca8c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 18 Nov 2024 20:53:52 +0100 Subject: [PATCH 14/19] Remove blank lines --- examples/tutorials/basics/polygons.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index e6d9e0c298f..7b6975deae9 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -52,10 +52,8 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) - # Fill the polygon with color "orange" fig.plot(x=x, y=y, fill="orange", pen="2p,darkred,dashed") - fig.show() @@ -74,14 +72,12 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) - fig.plot(x=x, y=y, pen=True) fig.shift_origin(xshift="w+1c") -fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x, y=y, pen=True, close=True) - fig.show() # %% @@ -89,14 +85,12 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) - fig.plot(x=x, y=y, pen=True) fig.shift_origin(xshift="w+1c") -fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) fig.plot(x=x, y=y, pen=True, fill="orange") - fig.show() # sphinx_gallery_thumbnail_number = 3 From 1ae944549812db1d32604b3436c92e0669c2a3d8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 24 Nov 2024 02:25:56 +0100 Subject: [PATCH 15/19] Add definition for 'polygon' --- examples/tutorials/basics/polygons.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index 7b6975deae9..dfd0feb5bc9 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -5,8 +5,11 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, -array-like objects are supported. For plotting a :class:`geopandas.GeoDataFrame` object -with polygon geometries, e.g. to create a choropleth map, see the gallery example +array-like objects are supported. Here, a polygon is a closed shape defined by a +series of data points with x and y coordinates, connected by line segments, with +the start and end points being identical. For plotting a +:class:`geopandas.GeoDataFrame` object with polygon geometries, e.g. to create a +choropleth map, see the gallery example :doc:`Choropleth map `. """ From 7463a822d729851caf19d881ef7f65bcecef6b95 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 24 Nov 2024 22:36:52 +0100 Subject: [PATCH 16/19] Mention default change when 'fill' is used --- examples/tutorials/basics/polygons.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index dfd0feb5bc9..a9252be90b6 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -51,12 +51,14 @@ # %% # Use the ``fill`` parameter to fill the polygon with a color or -# :doc:`pattern `. +# :doc:`pattern `. Note, that there are no lines drawn between the +# data points by default if ``fill`` is used. Use the ``pen`` parameter to add an +# outline around the polygon. fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) # Fill the polygon with color "orange" -fig.plot(x=x, y=y, fill="orange", pen="2p,darkred,dashed") +fig.plot(x=x, y=y, fill="orange") fig.show() From cbcb1c28469638487ce92ac1d7cc0b1c8060d7b2 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 24 Nov 2024 22:42:20 +0100 Subject: [PATCH 17/19] Re-wrapp to 88 chars --- examples/tutorials/basics/polygons.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index a9252be90b6..eab1de42ae9 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -4,12 +4,11 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. -This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, -array-like objects are supported. Here, a polygon is a closed shape defined by a -series of data points with x and y coordinates, connected by line segments, with -the start and end points being identical. For plotting a -:class:`geopandas.GeoDataFrame` object with polygon geometries, e.g. to create a -choropleth map, see the gallery example +This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, array- +like objects are supported. Here, a polygon is a closed shape defined by a series of +data points with x and y coordinates, connected by line segments, with the start and +end points being identical. For plotting a :class:`geopandas.GeoDataFrame` object with +polygon geometries, e.g. to create a choropleth map, see the gallery example :doc:`Choropleth map `. """ @@ -39,9 +38,9 @@ fig.show() # %% -# The ``pen`` parameter can be used to adjust the lines or outline of the polygon. -# The argument passed to ``pen`` is one string with the comma-separated optional -# values *width*,\ *color*,\ *style*. +# The ``pen`` parameter can be used to adjust the lines or outline of the polygon. The +# argument passed to ``pen`` is one string with the comma-separated optional values +# *width*,\ *color*,\ *style*. fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) @@ -66,8 +65,8 @@ # Close polygons # -------------- # -# Set up sample data points as NumPy array for the x and y values. Now, -# the data points do not form a polygon. +# Set up sample data points as NumPy array for the x and y values. Now, the data points +# do not form a polygon. x = np.array([-2, 1, 3, 0, -4]) y = np.array([-3, -1, 1, 3, 2]) From 982bb83d573d475762bb766dffddc1c26c515f95 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 24 Nov 2024 22:46:34 +0100 Subject: [PATCH 18/19] Adjust thumbnail_number --- examples/tutorials/basics/polygons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index eab1de42ae9..bb3fd844fb7 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -97,4 +97,4 @@ fig.plot(x=x, y=y, pen=True, fill="orange") fig.show() -# sphinx_gallery_thumbnail_number = 3 +# sphinx_gallery_thumbnail_number = 5 From 2a7cf631c7dc9f5520211e5ee771717c5f98528f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 25 Nov 2024 09:37:47 +0100 Subject: [PATCH 19/19] Write hypen-separated word in one line to avoid white space the two parts of the word --- examples/tutorials/basics/polygons.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/basics/polygons.py b/examples/tutorials/basics/polygons.py index bb3fd844fb7..6b3b4d37263 100644 --- a/examples/tutorials/basics/polygons.py +++ b/examples/tutorials/basics/polygons.py @@ -4,11 +4,11 @@ Plotting polygons is handled by the :meth:`pygmt.Figure.plot` method. -This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, array- -like objects are supported. Here, a polygon is a closed shape defined by a series of -data points with x and y coordinates, connected by line segments, with the start and +This tutorial focuses on input data given as NumPy arrays. Besides NumPy arrays, +array-like objects are supported. Here, a polygon is a closed shape defined by a series +of data points with x and y coordinates, connected by line segments, with the start and end points being identical. For plotting a :class:`geopandas.GeoDataFrame` object with -polygon geometries, e.g. to create a choropleth map, see the gallery example +polygon geometries, e.g., to create a choropleth map, see the gallery example :doc:`Choropleth map `. """