From 0ad18b1706cf056dd1f546b8cd567fc4befa8536 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 19 Dec 2020 08:51:19 +0000 Subject: [PATCH 01/13] Add the shading parameter to colorbar() in base_plotting.py --- pygmt/base_plotting.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 45f0cc6ef35..5ce22b7baf3 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -153,6 +153,7 @@ def coast(self, **kwargs): D="position", F="box", G="truncate", + I="shading", W="scale", V="verbose", X="xshift", @@ -223,6 +224,8 @@ def colorbar(self, **kwargs): scale : float Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. + shading : bool + Set shading for the colorbar. {V} {XY} {p} From 917000055b22bb07209f31f11bd2565fbf6c24c2 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 19 Dec 2020 08:54:40 +0000 Subject: [PATCH 02/13] Changing "colorbar" to "color bar" in comment --- pygmt/base_plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 5ce22b7baf3..1b105f32081 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -225,7 +225,7 @@ def colorbar(self, **kwargs): Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. shading : bool - Set shading for the colorbar. + Set shading for the color bar. {V} {XY} {p} From 03e21dc762e8c64201e2a17dee6e23c131dc6d47 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 20 Dec 2020 10:07:35 +0000 Subject: [PATCH 03/13] Update colorbar() shading description --- pygmt/base_plotting.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 3efe94b3dc0..9cb2f2f676a 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -224,8 +224,11 @@ def colorbar(self, **kwargs): scale : float Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. - shading : bool - Set shading for the color bar. + shading : str or bool + Add illumination effects. Optionally, set the range of intensities from + -max_intens to +max_intens. If not specified, 1 is used. Alternatively, + append low/high intensities to specify an asymmetric range. + The default is no illumination. {V} {XY} {p} From bbfe4ff5d25594d31c359c167490646e6bd5f07e Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 21 Dec 2020 07:55:49 +0000 Subject: [PATCH 04/13] Add shading to kwargs decorator; change shading inputs to include list --- pygmt/base_plotting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 9cb2f2f676a..37bd87be892 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -161,7 +161,7 @@ def coast(self, **kwargs): p="perspective", t="transparency", ) - @kwargs_to_strings(R="sequence", G="sequence", p="sequence") + @kwargs_to_strings(R="sequence", G="sequence", p="sequence", I="sequence") def colorbar(self, **kwargs): """ Plot a gray or color scale-bar on maps. @@ -224,7 +224,7 @@ def colorbar(self, **kwargs): scale : float Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. - shading : str or bool + shading : str or list or bool Add illumination effects. Optionally, set the range of intensities from -max_intens to +max_intens. If not specified, 1 is used. Alternatively, append low/high intensities to specify an asymmetric range. From c112bb34f2084b656f76300f11fcc634b12646be Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 21 Dec 2020 08:29:13 +0000 Subject: [PATCH 05/13] Format commen in base_plotting.py to meet line length requirements --- pygmt/base_plotting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 37bd87be892..fba4166057a 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -225,10 +225,10 @@ def colorbar(self, **kwargs): Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. shading : str or list or bool - Add illumination effects. Optionally, set the range of intensities from - -max_intens to +max_intens. If not specified, 1 is used. Alternatively, - append low/high intensities to specify an asymmetric range. - The default is no illumination. + Add illumination effects. Optionally, set the range of intensities + from -max_intens to +max_intens. If not specified, 1 is used. + Alternatively, append low/high intensities to specify an + asymmetric range. The default is no illumination. {V} {XY} {p} From 31a03b929a262fb839d848e931664ab0a71468db Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 08:22:43 +0000 Subject: [PATCH 06/13] Update pygmt/base_plotting.py Co-authored-by: Dongdong Tian --- pygmt/base_plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index fba4166057a..8cdd1487b0d 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -161,7 +161,7 @@ def coast(self, **kwargs): p="perspective", t="transparency", ) - @kwargs_to_strings(R="sequence", G="sequence", p="sequence", I="sequence") + @kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence") def colorbar(self, **kwargs): """ Plot a gray or color scale-bar on maps. From 071e9698c78e4ef91d9456acc5aa0b6a36cf52b8 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 08:22:50 +0000 Subject: [PATCH 07/13] Update pygmt/base_plotting.py Co-authored-by: Dongdong Tian --- pygmt/base_plotting.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 8cdd1487b0d..29cd8e5bea9 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -227,8 +227,9 @@ def colorbar(self, **kwargs): shading : str or list or bool Add illumination effects. Optionally, set the range of intensities from -max_intens to +max_intens. If not specified, 1 is used. - Alternatively, append low/high intensities to specify an - asymmetric range. The default is no illumination. + Alternatively, set ``shading=[low, high]`` to specify an + asymmetric intensity range from *low* to *high*. + The default is no illumination. {V} {XY} {p} From c1ad8810b9ea819161d7481b4df6cbb588b0701a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 08:38:56 +0000 Subject: [PATCH 08/13] Run make format --- pygmt/base_plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 29cd8e5bea9..1e8257f6ec0 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -228,7 +228,7 @@ def colorbar(self, **kwargs): Add illumination effects. Optionally, set the range of intensities from -max_intens to +max_intens. If not specified, 1 is used. Alternatively, set ``shading=[low, high]`` to specify an - asymmetric intensity range from *low* to *high*. + asymmetric intensity range from *low* to *high*. The default is no illumination. {V} {XY} From c8576b4cac7a0cf5122a6bda69a2131fe8fa1457 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 08:39:09 +0000 Subject: [PATCH 09/13] Add colorbar shading tests to test_colorbar.py --- pygmt/tests/test_colorbar.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/pygmt/tests/test_colorbar.py b/pygmt/tests/test_colorbar.py index f03002eb078..214a185b151 100644 --- a/pygmt/tests/test_colorbar.py +++ b/pygmt/tests/test_colorbar.py @@ -154,3 +154,63 @@ def test_colorbar_scaled_z_values(): fig = Figure() fig.colorbar(cmap="rainbow", scale=0.1, position="x0c/0c+w2c/0.5c") return fig + + +@check_figures_equal() +def test_colorbar_shading_boolean(): + """ + Create colorbar and set shading with a Boolean value + """ + fig_ref, fig_test = Figure(), Figure() + # Use single-character arguments for the reference image + fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") + fig_ref.colorbar(C="geo", I=True) + + fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") + fig_test.colorbar(cmap="geo", shading=True) + return fig_ref, fig_test + + +@check_figures_equal() +def test_colorbar_shading_float(): + """ + Create colorbar and set shading with a single float variable + """ + fig_ref, fig_test = Figure(), Figure() + # Use single-character arguments for the reference image + fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") + fig_ref.colorbar(C="geo", I="0.5") + + fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") + fig_test.colorbar(cmap="geo", shading=0.5) + return fig_ref, fig_test + + +@check_figures_equal() +def test_colorbar_shading_string(): + """ + Create colorbar and set shading by passing the high/low values as a string + """ + fig_ref, fig_test = Figure(), Figure() + # Use single-character arguments for the reference image + fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") + fig_ref.colorbar(C="geo", I="-0.7/0.2") + + fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") + fig_test.colorbar(cmap="geo", shading="-0.7/0.2") + return fig_ref, fig_test + + +@check_figures_equal() +def test_colorbar_shading_list(): + """ + Create colorbar and set shading by passing the high/low values as a list + """ + fig_ref, fig_test = Figure(), Figure() + # Use single-character arguments for the reference image + fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") + fig_ref.colorbar(C="geo", I="-0.7/0.2") + + fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") + fig_test.colorbar(cmap="geo", shading=[-0.7, 0.2]) + return fig_ref, fig_test From ca51048a8391ca28a87267c5ea2c7f9686e80771 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 09:15:27 +0000 Subject: [PATCH 10/13] Update pygmt/tests/test_colorbar.py Co-authored-by: Dongdong Tian --- pygmt/tests/test_colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_colorbar.py b/pygmt/tests/test_colorbar.py index 214a185b151..1747bb815e1 100644 --- a/pygmt/tests/test_colorbar.py +++ b/pygmt/tests/test_colorbar.py @@ -189,7 +189,7 @@ def test_colorbar_shading_float(): @check_figures_equal() def test_colorbar_shading_string(): """ - Create colorbar and set shading by passing the high/low values as a string + Create colorbar and set shading by passing the low/high values as a string """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image From 46239b6c0ec37de5bdc7bb0fcf0656786cb14924 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 09:15:34 +0000 Subject: [PATCH 11/13] Update pygmt/tests/test_colorbar.py Co-authored-by: Dongdong Tian --- pygmt/tests/test_colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_colorbar.py b/pygmt/tests/test_colorbar.py index 1747bb815e1..c54cea33395 100644 --- a/pygmt/tests/test_colorbar.py +++ b/pygmt/tests/test_colorbar.py @@ -164,7 +164,7 @@ def test_colorbar_shading_boolean(): fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") - fig_ref.colorbar(C="geo", I=True) + fig_ref.colorbar(C="geo", I="") fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig_test.colorbar(cmap="geo", shading=True) From 365c576f989971d63dc9cf745ff79daface942b6 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 09:15:38 +0000 Subject: [PATCH 12/13] Update pygmt/tests/test_colorbar.py Co-authored-by: Dongdong Tian --- pygmt/tests/test_colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_colorbar.py b/pygmt/tests/test_colorbar.py index c54cea33395..19a80d1e7ee 100644 --- a/pygmt/tests/test_colorbar.py +++ b/pygmt/tests/test_colorbar.py @@ -179,7 +179,7 @@ def test_colorbar_shading_float(): fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/10/0/10", J="X15c", B="a") - fig_ref.colorbar(C="geo", I="0.5") + fig_ref.colorbar(C="geo", I=0.5) fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig_test.colorbar(cmap="geo", shading=0.5) From 1233274c6bd4904e511626cc7be35254116a46d5 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 22 Dec 2020 09:34:44 +0000 Subject: [PATCH 13/13] Rewording explanation for colorbar shading parameter in base_plotting.py --- pygmt/base_plotting.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 75f19ed1ce4..56feb24846f 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -225,11 +225,10 @@ def colorbar(self, **kwargs): Multiply all z-values in the CPT by the provided scale. By default the CPT is used as is. shading : str or list or bool - Add illumination effects. Optionally, set the range of intensities - from -max_intens to +max_intens. If not specified, 1 is used. - Alternatively, set ``shading=[low, high]`` to specify an - asymmetric intensity range from *low* to *high*. - The default is no illumination. + Add illumination effects. Passing a single numerical value sets the range + of intensities from -value to +value. If not specified, 1 is used. + Alternatively, set ``shading=[low, high]`` to specify an asymmetric + intensity range from *low* to *high*. The default is no illumination. {V} {XY} {p}