Cannot preview Gadfly saved images

question

#1

I am using VS Code and Solarized Dark theme. When I save a Gadfly image, I could not preview it with my image viewer (the whole image looks dark and I can barely see anything). I thought the image has dark background, however when I insert the image in my Latex file, it has a white background.

My code is like:


using Gadfly Cairo
figure_1a = plot(sample_option, x = :strike_price, y = :impvol, Geom.line);
        draw(PNG("01.png", 10inch, 10inch), figure_1a)

The preview is like this

When I upload it to website, it is like this

When I preview it with shotwell viewer, its background becomes black


#2

It’s just a transparent background. To get a white background, then just add Theme(background_color = "white") to your Gadfly commands… Here’s the doc page with other theme commands: http://gadflyjl.org/stable/man/themes.html#Parameters-1


#3

Thanks so much! I saw these commands before, but I am not sure what options are available for them. Are there any docs covering that? For example, what values could background_color take?


#4

Oh man, there’s no colors() command like there is in R. It looks like they use the same color names as R, so you could use a cheatsheet like this one. The most useful thing in R for colors was Brewer colors, to make diverging palletes, colorblind friendly, and so on. The Colors Package seems to cover that, but Gadfly doesn’t seem to have fundamentals to automatically use the right kind of palette, like scale_color_brewer() did in R. Ah, the good old days.


#5

see https://github.com/JuliaGraphics/Colors.jl/blob/master/src/names_data.jl or try using Colors; keys(Colors.color_names)


#6

this might be the equivalent of scale_color_brewer: https://github.com/JuliaGraphics/Colors.jl#distinguishable_colors

julia> distinguishable_colors(3)
3-element Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},1}:
 RGB{N0f8}(0.0,0.0,0.0)  
 RGB{N0f8}(1.0,1.0,0.384)
 RGB{N0f8}(1.0,0.624,1.0)