Diverging Colormap (like RdBu) with opacity going from 1 to 0 in the middle and back to 1

406 views
Skip to first unread message

Patrick Kofod Mogensen

unread,
Feb 12, 2016, 4:48:06 AM2/12/16
to julia-users
Is it possible to create a colormap as described in the title using Colors.jl? I couldn't seem to find anything on Colormaps and transparency/opacity.

Best,
Patrick

Andreas Lobinger

unread,
Feb 12, 2016, 5:19:28 AM2/12/16
to julia-users
In the discussions about ColorTypes it showed up, that the majority prefered color independent of opacity. I'd guess you need to get the colormap via Colors.jl and then add the opacity information (created by linscale etc.). But i'm not sure that applying a color defined as color+transparency (RGBA etc.) is clearly defined in all cases. At least in plotting/rendering using RGB is prevalent.

Patrick Kofod Mogensen

unread,
Feb 12, 2016, 5:34:58 AM2/12/16
to julia-users
Actually, it came up in a plotting context https://github.com/tbreloff/Plots.jl/issues/138 . The use case is to overlay colors on a world map where blue means colder than average and red means warmer than average. Of course, if there is not much difference from the average, you don't want it to be white, you want it to be transparent, such that you can actually see the map. Thanks for pointing me towards the discussion in ColorTypes.jl

Andreas Lobinger

unread,
Feb 12, 2016, 6:52:58 AM2/12/16
to julia-users
discussion was about ColorTypes but not in -> https://github.com/JuliaLang/Color.jl/issues/101

Steven G. Johnson

unread,
Feb 12, 2016, 7:30:00 AM2/12/16
to julia-users


On Friday, February 12, 2016 at 5:19:28 AM UTC-5, Andreas Lobinger wrote:
In the discussions about ColorTypes it showed up, that the majority prefered color independent of opacity. I'd guess you need to get the colormap via Colors.jl and then add the opacity information (created by linscale etc.). But i'm not sure that applying a color defined as color+transparency (RGBA etc.) is clearly defined in all cases. At least in plotting/rendering using RGB is prevalent.

Matplotlib (via PyPlot) allows you to define a colormap with an alpha channel.

Peter Kovesi

unread,
Feb 12, 2016, 7:32:12 AM2/12/16
to julia-users
I have recently added a package for generating a variety of perceptually uniform colour maps which may be of interest to you
However I do not consider transparency

Cheers
Peter

Tom Breloff

unread,
Feb 12, 2016, 9:11:19 AM2/12/16
to julia...@googlegroups.com
Patrick I have solutions for custom colormaps with alpha in Plots... Maybe this thread is good motivation to dedicate a page in the documentation. The gist is that you can pass in a ColorGradient, which you can construct with predefined gradient names, custom color vectors, and custom interpolation points. Do a search for ColorGradient in the Plots issues and you should find some examples. 

Tom Breloff

unread,
Feb 12, 2016, 9:18:51 AM2/12/16
to julia...@googlegroups.com
Peter: your package looks interesting... I may add the ability to pass your colormap objects directly into Plots functions. I'll open an issue when I have a chance and cc you. 

Tom Breloff

unread,
Feb 12, 2016, 10:33:55 AM2/12/16
to julia...@googlegroups.com
For reference, I just added an example of color gradients with alpha here: https://github.com/tbreloff/Plots.jl/issues/138#issuecomment-183374401
Reply all
Reply to author
Forward
0 new messages