Skip to content

Clarify that the "transparency" parameter in plot/plot3d/text can be 1d array #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 20, 2021
Merged
2 changes: 1 addition & 1 deletion pygmt/src/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
for symbols, but this option is only valid if using x/y.
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access

Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def plot3d(
{p}
{t}
*transparency* can also be a 1d array to set varying transparency
for symbols.
for symbols, but this option is only valid if using x/y/z.
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access

Expand Down
2 changes: 2 additions & 0 deletions pygmt/src/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def text_(
{f}
{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/text.
"""

# pylint: disable=too-many-locals
Expand Down
8 changes: 5 additions & 3 deletions pygmt/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions pygmt/tests/test_plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down