GenericMappingTools / pygmt

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

Varying transparency levels for plot, plot3d and text #615

Closed seisman closed 3 years ago

seisman commented 4 years ago

Description of the desired feature

614 added the transparency argument to all plotting functions. In most functions, transparency can be an int/float value in 0-100. For a few functions (plot, plot3d and text), transparency can be a list to have varying transparency for symbols and texts.

We should extend these functions to support the varying transparency feature.

Are you willing to help implement and maintain this feature? Yes

weiji14 commented 3 years ago

Record by record transparency has been added to plot at #626, and also plot3d at #471, so what's left is just adding it to text?

On a side note, we might want to add a test for grdimage with transparency. I'm getting this error on PyGMT v0.2.1, GMT 6.2.0_92c5676_2020.11.10 with ghostscript 9.53.3:

fig = pygmt.Figure()
fig.grdimage(grid="@earth_relief_01d", transparency=70)
fig.show()
GMTCLibError: Module 'psconvert' failed with status code 79:
psconvert [ERROR]: System call [gs -q -dNOPAUSE -dBATCH -dNOSAFER -dPDFSETTINGS=/prepress -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false -dUseFlateCompression=true -dEmbedAllFonts=true -dSubsetFonts=true -dMonoImageFilter=/FlateEncode -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dSCANCONVERTERTYPE=2 -dALLOWPSTRANSPARENCY -dMaxBitmap=2147483647 -dUseFastColor=true -dGraphicsAlphaBits=1 -dTextAlphaBits=1 -sDEVICE=pdfwrite  -g1772x886 -r300 -sOutputFile='/home/user/.gmt/sessions/gmt_session.62321/gmt_13_intermediate.pdf' '/home/user/.gmt/sessions/gmt_session.62321/psconvert_62321d.eps'] returned error 256.

Will submit a proper bug report once I can isolate the issue.

seisman commented 3 years ago

Record by record transparency has been added to plot at #626, and also plot3d at #471, so what's left is just adding it to text?

Yes, I think I already have a local branch for the text transparency. Will check if it works as expected and submit it later.

On a side note, we might want to add a test for grdimage with transparency. I'm getting this error on PyGMT v0.2.1, GMT 6.2.0_92c5676_2020.11.10 with ghostscript 9.53.3:

I can't reproduce your issue, using PyGMT v0.2.2.dev14+g1547ad41 + GMT 6.2.0_74efdca_2020.12.06 + Ghostscript 9.53.3 on macOS.

weiji14 commented 3 years ago

Yes, I think I already have a local branch for the text transparency. Will check if it works as expected and submit it later.

Great! No rush though, I was just searching for transparency examples and saw this issue was still open

On a side note, we might want to add a test for grdimage with transparency. I'm getting this error on PyGMT v0.2.1, GMT 6.2.0_92c5676_2020.11.10 with ghostscript 9.53.3:

I can't reproduce your issue, using PyGMT v0.2.2.dev14+g1547ad41 + GMT 6.2.0_74efdca_2020.12.06 + Ghostscript 9.53.3 on macOS.

Yeah, I might need to update my GMT dev version, can't reproduce this on try-gmt either :/ Maybe https://github.com/GenericMappingTools/gmt/pull/4464 fixed this.