GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
758 stars 220 forks source link

The transparency parameter of plot/plot3d methods can be 1d array #1098

Closed core-man closed 3 years ago

core-man commented 3 years ago

Description of the problem

We need to update the documentation for the transparency parameter in plot and plot3d because transparency can also be 1d array.


See the description of the transparency parameter of plot:

transparency (int or float) – Set transparency level, in [0-100] percent range. Default is 0, i.e., opaque. Only visible when PDF or raster format output is selected. Only the PNG format selection adds a transparency layer in the image (for further processing). transparency can also be a 1d array to set varying transparency for symbols.

See the description of the transparency parameter of plot3d:

transparency (int or float) – Set transparency level, in [0-100] percent range. Default is 0, i.e., opaque. Only visible when PDF or raster format output is selected. Only the PNG format selection adds a transparency layer in the image (for further processing). transparency can also be a 1d array to set varying transparency for symbols.

We can see that transparency can be 1d array at the end of the above description, but it is missing at the beginning. See the example of Points with varying transparency using a 1d array as transparency.


Meanwhile, array-like transparency doesn't work for the data parameter. It is only valid for x/y like the sizes parameter. (originally posted in https://github.com/GenericMappingTools/pygmt/pull/1065#discussion_r598100163).

A GMTInvalidInput is raised for an array-like transparency when the data parameter is used in #1065. We may add a test for this kind of invalid input. A test called test_plot_fail_color_size_intensity is updated in #1065 for 1d-array color, sizes, and intensity when data parameter is used. It should be easy to add transparency in this test function, which may have a more general name, e.g.,test_plot_fail_1d_array_with_data

seisman commented 3 years ago

Sounds good to me.