From 9d4eb952041caece9efe083b0aeb89ec1cc6336f Mon Sep 17 00:00:00 2001 From: core-man Date: Sun, 9 May 2021 19:39:13 +0800 Subject: [PATCH 1/6] 1d array transparency is only valid for x/y in plot/plot3d --- pygmt/src/plot.py | 2 +- pygmt/src/plot3d.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index deac3f833ae..2fbdff48525 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -203,7 +203,7 @@ def plot(self, x=None, y=None, data=None, size=None, direction=None, **kwargs): {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols. + for symbols, but it is only valid if using x/y. """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index 42687165787..ff383785983 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -167,7 +167,7 @@ def plot3d( {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols. + for symbols, but it is only valid if using x/y. """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access From 8eb136937890c65d434c9928706601fbb9e12824 Mon Sep 17 00:00:00 2001 From: core-man Date: Wed, 19 May 2021 15:21:27 +0800 Subject: [PATCH 2/6] Rename test functions for 1d array input with data --- pygmt/tests/test_plot.py | 8 +++++--- pygmt/tests/test_plot3d.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pygmt/tests/test_plot.py b/pygmt/tests/test_plot.py index 2fff587d292..e2974b7da08 100644 --- a/pygmt/tests/test_plot.py +++ b/pygmt/tests/test_plot.py @@ -91,10 +91,10 @@ def test_plot_fail_no_data(data): ) -def test_plot_fail_color_size_intensity(data): +def test_plot_fail_1d_array_with_data(data): """ - Should raise an exception if array color, size and intensity are used with - matrix. + Should raise an exception if array color, size, intensity and transparency + are used with matrix. """ fig = Figure() kwargs = dict(data=data, region=region, projection="X10c", frame="afg") @@ -104,6 +104,8 @@ def test_plot_fail_color_size_intensity(data): fig.plot(style="cc", size=data[:, 2], color="red", **kwargs) with pytest.raises(GMTInvalidInput): fig.plot(style="c0.2c", color="red", intensity=data[:, 2], **kwargs) + with pytest.raises(GMTInvalidInput): + fig.plot(style="c0.2c", color="red", transparency=data[:, 2] * 100, **kwargs) @pytest.mark.mpl_image_compare diff --git a/pygmt/tests/test_plot3d.py b/pygmt/tests/test_plot3d.py index 05708f7f67a..02464831f39 100644 --- a/pygmt/tests/test_plot3d.py +++ b/pygmt/tests/test_plot3d.py @@ -108,10 +108,10 @@ def test_plot3d_fail_no_data(data, region): ) -def test_plot3d_fail_color_size_intensity(data, region): +def test_plot3d_fail_1d_array_with_data(data, region): """ - Should raise an exception if array color, size and intensity are used with - matrix. + Should raise an exception if array color, size, intensity and transparency + are used with matrix. """ fig = Figure() kwargs = dict(data=data, region=region, projection="X10c", frame="afg") @@ -121,6 +121,8 @@ def test_plot3d_fail_color_size_intensity(data, region): fig.plot3d(style="cc", size=data[:, 2], color="red", **kwargs) with pytest.raises(GMTInvalidInput): fig.plot3d(style="cc", intensity=data[:, 2], color="red", **kwargs) + with pytest.raises(GMTInvalidInput): + fig.plot3d(style="cc", color="red", transparency=data[:, 2] * 100, **kwargs) @pytest.mark.mpl_image_compare From b32bad2de97a98560ae2e09ca946930970e2e79b Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Thu, 20 May 2021 13:10:08 +0800 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/plot.py | 2 +- pygmt/src/plot3d.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index 26605f59727..1bd6e314261 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -204,7 +204,7 @@ def plot(self, x=None, y=None, data=None, size=None, direction=None, **kwargs): {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols, but it is only valid if using x/y. + for symbols, but this option is only valid if using x/y. """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index f4615938a5e..da073c24ec9 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -168,7 +168,7 @@ def plot3d( {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols, but it is only valid if using x/y. + for symbols, but this option is only valid if using x/y. """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access From 505ec41cec79e6b6b0b0959079f92345e604e2f8 Mon Sep 17 00:00:00 2001 From: core-man Date: Thu, 20 May 2021 13:53:32 +0800 Subject: [PATCH 4/6] Clarify transparency in text --- pygmt/src/text.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/text.py b/pygmt/src/text.py index 9db7d35bac4..d87f6c673f8 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -147,6 +147,8 @@ def text_( {f} {p} {t} + *transparency* can also be a 1d array to set varying transparency + for symbols, but this option is only valid if using x/y. """ # pylint: disable=too-many-locals From c3d02239da49488397029017d445781066ad0381 Mon Sep 17 00:00:00 2001 From: core-man Date: Thu, 20 May 2021 13:55:25 +0800 Subject: [PATCH 5/6] Fix typo --- pygmt/src/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/text.py b/pygmt/src/text.py index d87f6c673f8..b397ad6566b 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -148,7 +148,7 @@ def text_( {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols, but this option is only valid if using x/y. + for texts, but this option is only valid if using x/y. """ # pylint: disable=too-many-locals From 1c44042c3db3effc3d68ee85987797c7ec3cd1c1 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Thu, 20 May 2021 13:58:46 +0800 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/plot3d.py | 2 +- pygmt/src/text.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index da073c24ec9..50d22e58660 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -168,7 +168,7 @@ def plot3d( {p} {t} *transparency* can also be a 1d array to set varying transparency - for symbols, but this option is only valid if using x/y. + for symbols, but this option is only valid if using x/y/z. """ kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access diff --git a/pygmt/src/text.py b/pygmt/src/text.py index b397ad6566b..950748c10ee 100644 --- a/pygmt/src/text.py +++ b/pygmt/src/text.py @@ -148,7 +148,7 @@ def text_( {p} {t} *transparency* can also be a 1d array to set varying transparency - for texts, but this option is only valid if using x/y. + for texts, but this option is only valid if using x/y/text. """ # pylint: disable=too-many-locals