Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom color map in Gadfly.jl?

Tags:

julia

gadfly

What is the best way of adding a custom color map to a theme in Gadfly.jl? Say if I create a new color map as follows:

n = 12
color_map = distinguishable_colors(n, Color[LCHab(50, 60, 290)],
                       transform=c -> deuteranopic(c, 1),
                       lchoices=Float64[65, 30, 50, 50],
                       cchoices=Float64[0, 50, 60, 70],
                       hchoices=linspace(0, 50, 24))

(based on https://github.com/dcjones/Gadfly.jl/issues/602). How can I pass this to a Theme object so that my plots use this color map instead of the default one? The default_color parameter to Theme only takes one value.

like image 582
tlnagy Avatar asked Apr 11 '16 18:04

tlnagy


1 Answers

I've been struggling with this and related issues myself, which is NOT a qualification for offering a reliable answer. But you've been waiting two months, so I'll give it my best try.

I believe that the default_color parameter to a theme is in fact just a single color, not a color mapping function. To use a colormap, you need to bind it to a "color aesthetic," such as the color_continuous or color_discrete_hue scales. And it needs to be defined as a function that accepts an argument in the range [0, 1] and returns a color value (for example, RGB(r, g, b)).

There's a bit of explanation in the Gadfly docs at http://dcjones.github.io/Gadfly.jl/scale_color_continuous.html

like image 109
bit-player Avatar answered Nov 17 '22 03:11

bit-player