Skip to content

Commit c411377

Browse files
core-manweiji14seisman
authored
Clarify that the "transparency" parameter in plot/plot3d/text can be 1d array (#1265)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent e92c0db commit c411377

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

pygmt/src/plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def plot(self, x=None, y=None, data=None, size=None, direction=None, **kwargs):
204204
{p}
205205
{t}
206206
*transparency* can also be a 1d array to set varying transparency
207-
for symbols.
207+
for symbols, but this option is only valid if using x/y.
208208
"""
209209
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
210210

pygmt/src/plot3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def plot3d(
168168
{p}
169169
{t}
170170
*transparency* can also be a 1d array to set varying transparency
171-
for symbols.
171+
for symbols, but this option is only valid if using x/y/z.
172172
"""
173173
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
174174

pygmt/src/text.py

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def text_(
147147
{f}
148148
{p}
149149
{t}
150+
*transparency* can also be a 1d array to set varying transparency
151+
for texts, but this option is only valid if using x/y/text.
150152
"""
151153

152154
# pylint: disable=too-many-locals

pygmt/tests/test_plot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def test_plot_fail_no_data(data):
9191
)
9292

9393

94-
def test_plot_fail_color_size_intensity(data):
94+
def test_plot_fail_1d_array_with_data(data):
9595
"""
96-
Should raise an exception if array color, size and intensity are used with
97-
matrix.
96+
Should raise an exception if array color, size, intensity and transparency
97+
are used with matrix.
9898
"""
9999
fig = Figure()
100100
kwargs = dict(data=data, region=region, projection="X10c", frame="afg")
@@ -104,6 +104,8 @@ def test_plot_fail_color_size_intensity(data):
104104
fig.plot(style="cc", size=data[:, 2], color="red", **kwargs)
105105
with pytest.raises(GMTInvalidInput):
106106
fig.plot(style="c0.2c", color="red", intensity=data[:, 2], **kwargs)
107+
with pytest.raises(GMTInvalidInput):
108+
fig.plot(style="c0.2c", color="red", transparency=data[:, 2] * 100, **kwargs)
107109

108110

109111
@pytest.mark.mpl_image_compare

pygmt/tests/test_plot3d.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def test_plot3d_fail_no_data(data, region):
108108
)
109109

110110

111-
def test_plot3d_fail_color_size_intensity(data, region):
111+
def test_plot3d_fail_1d_array_with_data(data, region):
112112
"""
113-
Should raise an exception if array color, size and intensity are used with
114-
matrix.
113+
Should raise an exception if array color, size, intensity and transparency
114+
are used with matrix.
115115
"""
116116
fig = Figure()
117117
kwargs = dict(data=data, region=region, projection="X10c", frame="afg")
@@ -121,6 +121,8 @@ def test_plot3d_fail_color_size_intensity(data, region):
121121
fig.plot3d(style="cc", size=data[:, 2], color="red", **kwargs)
122122
with pytest.raises(GMTInvalidInput):
123123
fig.plot3d(style="cc", intensity=data[:, 2], color="red", **kwargs)
124+
with pytest.raises(GMTInvalidInput):
125+
fig.plot3d(style="cc", color="red", transparency=data[:, 2] * 100, **kwargs)
124126

125127

126128
@pytest.mark.mpl_image_compare

0 commit comments

Comments
 (0)