From 7f870d3d577f6303b32ee52788099a68019b275e Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 25 Sep 2022 14:54:55 +0200 Subject: [PATCH 01/11] Add gallery example for ternary method --- examples/gallery/embellishments/ternary.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/gallery/embellishments/ternary.py diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py new file mode 100644 index 00000000000..9f4e70b5e1c --- /dev/null +++ b/examples/gallery/embellishments/ternary.py @@ -0,0 +1,18 @@ +import pygmt + +fig = pygmt.Figure() + +pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) + +fig.ternary("@ternary.txt", + region = [0, 100, 0, 100, 0, 100], + width = "10c", + style = "c0.1c", + L = "Water/Air/Limestone", + cmap = True, + frame = ['aafg+l"Water component"+u" %"', + 'bafg+l"Air component"+u" %"', + 'cagf+l"Limestone component"+u" %"', + "+givory"]) + +fig.show() From fdca55a6066ac564add140b31f4d97ca91beea91 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 25 Sep 2022 15:13:14 +0200 Subject: [PATCH 02/11] format --- examples/gallery/embellishments/ternary.py | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index 9f4e70b5e1c..3952b1b5466 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -1,18 +1,31 @@ +""" +Ternary diagram +--------------------------------------- + +To plot circles (diameter = 0.1 cm) on a 6-inch-wide ternary diagram at the +positions listed in the file ternary.txt, with default annotations and +gridline spacings, using the specified labeling. +""" + import pygmt fig = pygmt.Figure() pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) -fig.ternary("@ternary.txt", - region = [0, 100, 0, 100, 0, 100], - width = "10c", - style = "c0.1c", - L = "Water/Air/Limestone", - cmap = True, - frame = ['aafg+l"Water component"+u" %"', - 'bafg+l"Air component"+u" %"', - 'cagf+l"Limestone component"+u" %"', - "+givory"]) +fig.ternary( + "@ternary.txt", + region=[0, 100, 0, 100, 0, 100], + width="10c", + style="c0.1c", + L="Water/Air/Limestone", + cmap=True, + frame=[ + 'aafg+l"Water component"+u" %"', + 'bafg+l"Air component"+u" %"', + 'cagf+l"Limestone component"+u" %"', + "+givory", + ], +) fig.show() From d0c9409b02945f27cf335545849d56c5fdbc8d34 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 6 Oct 2022 22:19:21 +0200 Subject: [PATCH 03/11] Update ternary.py --- examples/gallery/embellishments/ternary.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index 3952b1b5466..1f86fc46fe2 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -18,7 +18,9 @@ region=[0, 100, 0, 100, 0, 100], width="10c", style="c0.1c", - L="Water/Air/Limestone", + alabel="Water", + blabel="Air", + clabel="Limestone", cmap=True, frame=[ 'aafg+l"Water component"+u" %"', From 78d04c72d94f2e64c3100ef510ccbf5446bd8b2a Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 11 Dec 2022 16:48:10 +0100 Subject: [PATCH 04/11] Update ternary.py --- examples/gallery/embellishments/ternary.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index 1f86fc46fe2..bcb74567d76 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -2,7 +2,7 @@ Ternary diagram --------------------------------------- -To plot circles (diameter = 0.1 cm) on a 6-inch-wide ternary diagram at the +To plot circles (diameter = 0.1 cm) on a 10-centimeter-wide ternary diagram at the positions listed in the file ternary.txt, with default annotations and gridline spacings, using the specified labeling. """ @@ -11,21 +11,23 @@ fig = pygmt.Figure() +data = pygmt.datasets.load_sample_data(name="rock_compositions") + pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) fig.ternary( - "@ternary.txt", + data, region=[0, 100, 0, 100, 0, 100], width="10c", style="c0.1c", - alabel="Water", - blabel="Air", - clabel="Limestone", + alabel="Limestone", + blabel="Water", + clabel="Air", cmap=True, frame=[ - 'aafg+l"Water component"+u" %"', - 'bafg+l"Air component"+u" %"', - 'cagf+l"Limestone component"+u" %"', + 'aafg+l"Limestone component"+u" %"', + 'bafg+l"Water component"+u" %"', + 'cagf+l"Air component"+u" %"', "+givory", ], ) From 2e00aea6a2494c0ba36815a3eeeb4e03e4e09314 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 12 Dec 2022 17:29:49 +0100 Subject: [PATCH 05/11] Apply suggestions from code review Co-authored-by: Dongdong Tian Co-authored-by: Will Schlitzer --- examples/gallery/embellishments/ternary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index bcb74567d76..dbf6ed54f7b 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -1,9 +1,9 @@ """ Ternary diagram ---------------------------------------- +--------------- To plot circles (diameter = 0.1 cm) on a 10-centimeter-wide ternary diagram at the -positions listed in the file ternary.txt, with default annotations and +positions listed in the sample dataset `rock_compositions`, with default annotations and gridline spacings, using the specified labeling. """ From 2b452d53c2b90b3bc0529789e8d836de09ae5764 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Tue, 13 Dec 2022 09:54:13 +0100 Subject: [PATCH 06/11] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- examples/gallery/embellishments/ternary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index dbf6ed54f7b..53f31bee473 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -25,9 +25,9 @@ clabel="Air", cmap=True, frame=[ - 'aafg+l"Limestone component"+u" %"', - 'bafg+l"Water component"+u" %"', - 'cagf+l"Air component"+u" %"', + "aafg+lLimestone component+u %", + "bafg+lWater component+u %", + "cagf+lAir component+u %", "+givory", ], ) From 45a971827f2144e2257f591879f225af4c736090 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 26 Dec 2022 12:15:21 +0100 Subject: [PATCH 07/11] add docs --- examples/gallery/embellishments/ternary.py | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index 53f31bee473..eefe00bf4c9 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -1,18 +1,25 @@ """ Ternary diagram --------------- - -To plot circles (diameter = 0.1 cm) on a 10-centimeter-wide ternary diagram at the -positions listed in the sample dataset `rock_compositions`, with default annotations and -gridline spacings, using the specified labeling. +The pygmt.Figure.ternary method can draw ternary diagrams. The example shows +how to plot circles with a diameter of 0.1 centimeters (``style=0.1c``) on a +10-centimeter-wide (```width=10c``) ternary diagram at the positions listed +in the first three columns of the sample dataset `rock_compositions`, with +default annotations and gridline spacings, using the specified labeling +defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based +on the values given in the fourth columns of the sample dataset via +``cmap=True``. """ import pygmt fig = pygmt.Figure() +# Load sample data data = pygmt.datasets.load_sample_data(name="rock_compositions") +# Define a colormap to be used for the values given in the fourth column +# of the input dataset pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) fig.ternary( @@ -28,8 +35,14 @@ "aafg+lLimestone component+u %", "bafg+lWater component+u %", "cagf+lAir component+u %", - "+givory", ], ) +# Shift origin -1 centimeters in y direction to avoid overlap +# between ternary diagram and colorbar +fig.shift_origin(yshift="-1c") + +# Add a colorbar indicating the values given in the fourth column of +# the input dataset +fig.colorbar(frame=["x+lPermittivity"]) fig.show() From 335c672cf4baeb9dd0517d808d1f34af45fab3e7 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 26 Dec 2022 13:45:45 +0100 Subject: [PATCH 08/11] Apply suggestions from code review Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/ternary.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py index eefe00bf4c9..258d31bc370 100644 --- a/examples/gallery/embellishments/ternary.py +++ b/examples/gallery/embellishments/ternary.py @@ -1,10 +1,10 @@ """ Ternary diagram --------------- -The pygmt.Figure.ternary method can draw ternary diagrams. The example shows -how to plot circles with a diameter of 0.1 centimeters (``style=0.1c``) on a -10-centimeter-wide (```width=10c``) ternary diagram at the positions listed -in the first three columns of the sample dataset `rock_compositions`, with +The :meth:`pygmt.Figure.ternary` method can draw ternary diagrams. The example shows +how to plot circles with a diameter of 0.1 centimeters (``style="c0.1c"``) on a +10-centimeter-wide (``width="10c"``) ternary diagram at the positions listed +in the first three columns of the sample dataset ``rock_compositions``, with default annotations and gridline spacings, using the specified labeling defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based on the values given in the fourth columns of the sample dataset via @@ -38,11 +38,7 @@ ], ) -# Shift origin -1 centimeters in y direction to avoid overlap -# between ternary diagram and colorbar -fig.shift_origin(yshift="-1c") - # Add a colorbar indicating the values given in the fourth column of # the input dataset -fig.colorbar(frame=["x+lPermittivity"]) +fig.colorbar(position="JBC+o0c/1.5c", frame=["x+lPermittivity"]) fig.show() From 95c0b0623d2ab1afb8c30b895fc4207f34e4b183 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 26 Dec 2022 13:47:44 +0100 Subject: [PATCH 09/11] change category --- examples/gallery/basemaps/ternary.py | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 examples/gallery/basemaps/ternary.py diff --git a/examples/gallery/basemaps/ternary.py b/examples/gallery/basemaps/ternary.py new file mode 100644 index 00000000000..258d31bc370 --- /dev/null +++ b/examples/gallery/basemaps/ternary.py @@ -0,0 +1,44 @@ +""" +Ternary diagram +--------------- +The :meth:`pygmt.Figure.ternary` method can draw ternary diagrams. The example shows +how to plot circles with a diameter of 0.1 centimeters (``style="c0.1c"``) on a +10-centimeter-wide (``width="10c"``) ternary diagram at the positions listed +in the first three columns of the sample dataset ``rock_compositions``, with +default annotations and gridline spacings, using the specified labeling +defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based +on the values given in the fourth columns of the sample dataset via +``cmap=True``. +""" + +import pygmt + +fig = pygmt.Figure() + +# Load sample data +data = pygmt.datasets.load_sample_data(name="rock_compositions") + +# Define a colormap to be used for the values given in the fourth column +# of the input dataset +pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) + +fig.ternary( + data, + region=[0, 100, 0, 100, 0, 100], + width="10c", + style="c0.1c", + alabel="Limestone", + blabel="Water", + clabel="Air", + cmap=True, + frame=[ + "aafg+lLimestone component+u %", + "bafg+lWater component+u %", + "cagf+lAir component+u %", + ], +) + +# Add a colorbar indicating the values given in the fourth column of +# the input dataset +fig.colorbar(position="JBC+o0c/1.5c", frame=["x+lPermittivity"]) +fig.show() From c35ae1afd7b9ac6bc242eb8283c085ab36b3f986 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 26 Dec 2022 13:55:45 +0100 Subject: [PATCH 10/11] format --- examples/gallery/basemaps/ternary.py | 16 ++++---- examples/gallery/embellishments/ternary.py | 44 ---------------------- 2 files changed, 8 insertions(+), 52 deletions(-) delete mode 100644 examples/gallery/embellishments/ternary.py diff --git a/examples/gallery/basemaps/ternary.py b/examples/gallery/basemaps/ternary.py index 258d31bc370..864eaf058ac 100644 --- a/examples/gallery/basemaps/ternary.py +++ b/examples/gallery/basemaps/ternary.py @@ -1,14 +1,14 @@ """ Ternary diagram --------------- -The :meth:`pygmt.Figure.ternary` method can draw ternary diagrams. The example shows -how to plot circles with a diameter of 0.1 centimeters (``style="c0.1c"``) on a -10-centimeter-wide (``width="10c"``) ternary diagram at the positions listed -in the first three columns of the sample dataset ``rock_compositions``, with -default annotations and gridline spacings, using the specified labeling -defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based -on the values given in the fourth columns of the sample dataset via -``cmap=True``. +The :meth:`pygmt.Figure.ternary` method can draw ternary diagrams. The example +shows how to plot circles with a diameter of 0.1 centimeters +(``style="c0.1c"``) on a 10-centimeter-wide (``width="10c"``) ternary diagram +at the positions listed in the first three columns of the sample dataset +``rock_compositions``, with default annotations and gridline spacings, using +the specified labeling defined via ``alabel``, ``blabel`` and ``clabel``. +Points are colored based on the values given in the fourth columns of the +sample dataset via ``cmap=True``. """ import pygmt diff --git a/examples/gallery/embellishments/ternary.py b/examples/gallery/embellishments/ternary.py deleted file mode 100644 index 258d31bc370..00000000000 --- a/examples/gallery/embellishments/ternary.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -Ternary diagram ---------------- -The :meth:`pygmt.Figure.ternary` method can draw ternary diagrams. The example shows -how to plot circles with a diameter of 0.1 centimeters (``style="c0.1c"``) on a -10-centimeter-wide (``width="10c"``) ternary diagram at the positions listed -in the first three columns of the sample dataset ``rock_compositions``, with -default annotations and gridline spacings, using the specified labeling -defined via ``alabel``, ``blabel`` and ``clabel``. Points are colored based -on the values given in the fourth columns of the sample dataset via -``cmap=True``. -""" - -import pygmt - -fig = pygmt.Figure() - -# Load sample data -data = pygmt.datasets.load_sample_data(name="rock_compositions") - -# Define a colormap to be used for the values given in the fourth column -# of the input dataset -pygmt.makecpt(cmap="batlow", series=[0, 80, 10]) - -fig.ternary( - data, - region=[0, 100, 0, 100, 0, 100], - width="10c", - style="c0.1c", - alabel="Limestone", - blabel="Water", - clabel="Air", - cmap=True, - frame=[ - "aafg+lLimestone component+u %", - "bafg+lWater component+u %", - "cagf+lAir component+u %", - ], -) - -# Add a colorbar indicating the values given in the fourth column of -# the input dataset -fig.colorbar(position="JBC+o0c/1.5c", frame=["x+lPermittivity"]) -fig.show() From 80a29332ce3c7dff7e1379206b4166898910e30e Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 26 Dec 2022 19:24:42 +0100 Subject: [PATCH 11/11] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- examples/gallery/basemaps/ternary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/basemaps/ternary.py b/examples/gallery/basemaps/ternary.py index 864eaf058ac..40e308069b9 100644 --- a/examples/gallery/basemaps/ternary.py +++ b/examples/gallery/basemaps/ternary.py @@ -6,7 +6,7 @@ (``style="c0.1c"``) on a 10-centimeter-wide (``width="10c"``) ternary diagram at the positions listed in the first three columns of the sample dataset ``rock_compositions``, with default annotations and gridline spacings, using -the specified labeling defined via ``alabel``, ``blabel`` and ``clabel``. +the specified labeling defined via ``alabel``, ``blabel``, and ``clabel``. Points are colored based on the values given in the fourth columns of the sample dataset via ``cmap=True``. """