From 958a51340f9290291044567392e987798f38b9cc Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sat, 17 Jul 2021 14:32:34 +0300 Subject: [PATCH 01/18] Initial commit for contour gallery example --- examples/gallery/lines/contours.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 examples/gallery/lines/contours.py diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py new file mode 100644 index 00000000000..9d85cf7bcbf --- /dev/null +++ b/examples/gallery/lines/contours.py @@ -0,0 +1,5 @@ +""" +Contours +-------- +The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points. +""" \ No newline at end of file From b0a0908daa5d07318fb24449352840b4a882bd9e Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sat, 17 Jul 2021 15:20:48 +0300 Subject: [PATCH 02/18] adding a simple gallery example to the useability of contours. --- examples/gallery/lines/contours.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 9d85cf7bcbf..e84db969cad 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -2,4 +2,24 @@ Contours -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points. -""" \ No newline at end of file +""" + + +import numpy as np +import pygmt + +X, Y = np.meshgrid(np.linspace(-10, 10, 50), np.linspace(-10, 10, 50)) +Z = X**2 + Y**2 +x, y, z = X.flatten(), Y.flatten(), Z.flatten() + +fig = pygmt.Figure() +fig.contour( + region=[-10, 10, -10, 10], + projection="X10c/10c", + frame="ag", + x=x, + y=y, + z=z, + pen=1 +) +fig.show() \ No newline at end of file From 0b0cbbf70a3fdbdc6c262754379191156a8278e9 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 18 Jul 2021 08:52:30 +0300 Subject: [PATCH 03/18] Explain the acceptable data formats, levels, and annotation parameters. --- examples/gallery/lines/contours.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index e84db969cad..3121526c67d 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -1,7 +1,13 @@ """ Contours -------- -The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points. +The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. +The data to the triangulation can by provided in one of three options: + 1: ``x``, ``y``, ``z`` 1d data columns + 2: ``data`` 2d data matrix with 3 columns corresponding to ``x``, ``y``, ``z`` + 3: ''data'' path string to a file containing the ``x``, ``y``, ``z`` in a tabular format +The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the +annotation on the contours """ @@ -12,6 +18,7 @@ Z = X**2 + Y**2 x, y, z = X.flatten(), Y.flatten(), Z.flatten() + fig = pygmt.Figure() fig.contour( region=[-10, 10, -10, 10], @@ -20,6 +27,8 @@ x=x, y=y, z=z, + levels=5, + annotation=20, pen=1 ) fig.show() \ No newline at end of file From 4cf47a2d0ea1e849d87f4f79bab7d0e834ec2506 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 18 Jul 2021 09:00:53 +0300 Subject: [PATCH 04/18] adding inline comments --- examples/gallery/lines/contours.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 3121526c67d..42c8932a0ef 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -14,6 +14,7 @@ import numpy as np import pygmt +# building the contours underling data with the function z = x^2 + y^2 X, Y = np.meshgrid(np.linspace(-10, 10, 50), np.linspace(-10, 10, 50)) Z = X**2 + Y**2 x, y, z = X.flatten(), Y.flatten(), Z.flatten() @@ -24,11 +25,14 @@ region=[-10, 10, -10, 10], projection="X10c/10c", frame="ag", + pen=1, + # passing the data as 3 1d data columns x=x, y=y, z=z, + # set the contours z values intervals to 5 levels=5, - annotation=20, - pen=1 + # set the contours annotation intervals to 20 + annotation=20 ) fig.show() \ No newline at end of file From c105d4aded98fc0cb7138ce80d4f138e9881eaab Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 18 Jul 2021 09:20:42 +0300 Subject: [PATCH 05/18] minor corections --- examples/gallery/lines/contours.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 42c8932a0ef..2896d45dbfb 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -3,11 +3,11 @@ -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. The data to the triangulation can by provided in one of three options: - 1: ``x``, ``y``, ``z`` 1d data columns - 2: ``data`` 2d data matrix with 3 columns corresponding to ``x``, ``y``, ``z`` - 3: ''data'' path string to a file containing the ``x``, ``y``, ``z`` in a tabular format + 1: ``x``, ``y``, ``z`` 1d data columns\n + 2: ``data`` 2d data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n + 3: ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format\n The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the -annotation on the contours +annotation on the contours respectively """ From 6d4d3ee31cb47b9452d98d937fbdb02d688ef682 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Sun, 18 Jul 2021 11:02:31 +0300 Subject: [PATCH 06/18] adding a bit more explanation on the implementation, adding a reference to numpy ndarray, adding units to pen. --- examples/gallery/lines/contours.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 2896d45dbfb..336a2d67987 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -3,11 +3,14 @@ -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. The data to the triangulation can by provided in one of three options: - 1: ``x``, ``y``, ``z`` 1d data columns\n - 2: ``data`` 2d data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n + 1: ``x``, ``y``, ``z`` 1d :class:`numpy.ndarray` data columns\n + 2: ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n 3: ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format\n The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the -annotation on the contours respectively +annotation on the contours respectively.\n +In this example we supply the data as 1d :class:`numpy.ndarray` with the ``x``, ``y``, +and ``z`` parameters and draw the contours using a 0.5p pen with contours every 5 ``z`` values and +annotations every 20 ``z`` values. """ @@ -16,7 +19,7 @@ # building the contours underling data with the function z = x^2 + y^2 X, Y = np.meshgrid(np.linspace(-10, 10, 50), np.linspace(-10, 10, 50)) -Z = X**2 + Y**2 +Z = X ** 2 + Y ** 2 x, y, z = X.flatten(), Y.flatten(), Z.flatten() @@ -25,7 +28,7 @@ region=[-10, 10, -10, 10], projection="X10c/10c", frame="ag", - pen=1, + pen='0.5p', # passing the data as 3 1d data columns x=x, y=y, From 9b4e4f55f122128a551f456a9b619d1077bb1f97 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 19 Jul 2021 01:14:56 +0000 Subject: [PATCH 07/18] [format-command] fixes --- examples/gallery/lines/contours.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 336a2d67987..56a39839361 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -28,7 +28,7 @@ region=[-10, 10, -10, 10], projection="X10c/10c", frame="ag", - pen='0.5p', + pen="0.5p", # passing the data as 3 1d data columns x=x, y=y, @@ -36,6 +36,6 @@ # set the contours z values intervals to 5 levels=5, # set the contours annotation intervals to 20 - annotation=20 + annotation=20, ) -fig.show() \ No newline at end of file +fig.show() From 3c555fbd75b953101af35581db0fbbe6d93fc465 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:34:28 +0300 Subject: [PATCH 08/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 56a39839361..2bc596a36d7 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -7,7 +7,8 @@ 2: ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n 3: ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format\n The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the -annotation on the contours respectively.\n +annotation on the contours respectively. + In this example we supply the data as 1d :class:`numpy.ndarray` with the ``x``, ``y``, and ``z`` parameters and draw the contours using a 0.5p pen with contours every 5 ``z`` values and annotations every 20 ``z`` values. From 7b4b5a08585269725ddb60e634c8e4c4e4d837dc Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:34:52 +0300 Subject: [PATCH 09/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 2bc596a36d7..4377e712c50 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -2,7 +2,7 @@ Contours -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. -The data to the triangulation can by provided in one of three options: +The data to the triangulation can be provided in one of three options: 1: ``x``, ``y``, ``z`` 1d :class:`numpy.ndarray` data columns\n 2: ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n 3: ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format\n From 7b7724f55635011fb4a47f2aef71f89a3e995c9f Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:35:58 +0300 Subject: [PATCH 10/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 4377e712c50..257c57dca38 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -3,9 +3,13 @@ -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. The data to the triangulation can be provided in one of three options: - 1: ``x``, ``y``, ``z`` 1d :class:`numpy.ndarray` data columns\n - 2: ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding to ``x``, ``y``, ``z``\n - 3: ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format\n + +#. ``x``, ``y``, ``z`` 1d :class:`numpy.ndarray` data columns. +#. ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding + to ``x``, ``y``, ``z``. +#. ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a + tabular format. + The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the annotation on the contours respectively. From e07aed8b93030e491bbae5eb9d64c5f26996651c Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:36:38 +0300 Subject: [PATCH 11/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 257c57dca38..6d4dc522487 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -14,7 +14,7 @@ annotation on the contours respectively. In this example we supply the data as 1d :class:`numpy.ndarray` with the ``x``, ``y``, -and ``z`` parameters and draw the contours using a 0.5p pen with contours every 5 ``z`` values and +and ``z`` parameters and draw the contours using a 0.5p pen with contours every 10 ``z`` values and annotations every 20 ``z`` values. """ From 503ccef76a88f88f39edd506a9945f8537cb4b26 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:36:49 +0300 Subject: [PATCH 12/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 6d4dc522487..5348931242e 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -39,7 +39,7 @@ y=y, z=z, # set the contours z values intervals to 5 - levels=5, + levels=10, # set the contours annotation intervals to 20 annotation=20, ) From a703a8b469a67ab3ec04f075858b7c5f75ffc101 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:37:25 +0300 Subject: [PATCH 13/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 5348931242e..fe40ca3b50f 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -10,7 +10,7 @@ #. ``data`` path string to a file containing the ``x``, ``y``, ``z`` in a tabular format. -The parameters ``levels`` and ``annotation`` are deciding on the contours intervals and intervals of the +The parameters ``levels`` and ``annotation`` set the intervals of the contours and the annotation on the contours respectively. In this example we supply the data as 1d :class:`numpy.ndarray` with the ``x``, ``y``, From 0cf899c43a31e04f80a5d44c2ca4a85b77112058 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:37:40 +0300 Subject: [PATCH 14/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index fe40ca3b50f..4dfdc17c996 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -22,7 +22,7 @@ import numpy as np import pygmt -# building the contours underling data with the function z = x^2 + y^2 +# build the contours underlying data with the function z = x^2 + y^2 X, Y = np.meshgrid(np.linspace(-10, 10, 50), np.linspace(-10, 10, 50)) Z = X ** 2 + Y ** 2 x, y, z = X.flatten(), Y.flatten(), Z.flatten() From 72f99e51620c716c17a5266561e29a6c5e4ddfb3 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:37:55 +0300 Subject: [PATCH 15/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 4dfdc17c996..1f5df0875e1 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -34,7 +34,7 @@ projection="X10c/10c", frame="ag", pen="0.5p", - # passing the data as 3 1d data columns + # pass the data as 3 1d data columns x=x, y=y, z=z, From 64eded080b4665f56a2ea5d7ba9784eda3daee8d Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 06:38:12 +0300 Subject: [PATCH 16/18] Update examples/gallery/lines/contours.py Co-authored-by: Meghan Jones --- examples/gallery/lines/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/lines/contours.py index 1f5df0875e1..e9cfbe0c5b6 100644 --- a/examples/gallery/lines/contours.py +++ b/examples/gallery/lines/contours.py @@ -38,7 +38,7 @@ x=x, y=y, z=z, - # set the contours z values intervals to 5 + # set the contours z values intervals to 10 levels=10, # set the contours annotation intervals to 20 annotation=20, From 71bf2653a1bd0273420b67847a74bbc00d77e205 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Mon, 19 Jul 2021 07:45:31 +0300 Subject: [PATCH 17/18] moving the example from lines to images --- examples/gallery/{lines => images}/contours.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gallery/{lines => images}/contours.py (100%) diff --git a/examples/gallery/lines/contours.py b/examples/gallery/images/contours.py similarity index 100% rename from examples/gallery/lines/contours.py rename to examples/gallery/images/contours.py From 6529a9d815c7ddb4490b57a061b99d741110ac44 Mon Sep 17 00:00:00 2001 From: yohaimagen Date: Tue, 20 Jul 2021 08:25:09 +0300 Subject: [PATCH 18/18] Update examples/gallery/images/contours.py Co-authored-by: Will Schlitzer --- examples/gallery/images/contours.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/contours.py b/examples/gallery/images/contours.py index e9cfbe0c5b6..7624fab56da 100644 --- a/examples/gallery/images/contours.py +++ b/examples/gallery/images/contours.py @@ -2,7 +2,7 @@ Contours -------- The :meth:`pygmt.Figure.contour` method can plot contour lines from a table of points by direct triangulation. -The data to the triangulation can be provided in one of three options: +The data for the triangulation can be provided using one of three methods: #. ``x``, ``y``, ``z`` 1d :class:`numpy.ndarray` data columns. #. ``data`` 2d :class:`numpy.ndarray` data matrix with 3 columns corresponding