Changing geom color in Gadfly

Hi. I’m trying to change the line color in a graph I’m generating using Gadfly (in a Jupyter notebook).

p = plot(Coord.cartesian(xmin=-2, xmax=2, ymin=-2, ymax=2))
for i in 1:50
  push!(p, layer(x=d.A, y=prior_dists.α[i] .+ prior_dists.βA[i] * (d.A .- mean(d.A)), Geom.line, color=[colorant"black"]))

The above code generates the output


If I leave out the geom, the graph defaults to points and I get black points (likewise if I specify Geom.point). If I leave out color, I get lines, but in Gadfly’s default color.

Am I doing something wrong?


Geom.line is one geometry which still uses the syntax
layer(..., Geom.line, Theme(default_color="black")) to change line color. I’m currently working on new code which will allow for the syntax color=[colorant"black"] with Geom.line. :grinning:

OK. Thanks.

This is now available on Gadfly master (in julia: ]add Gadfly#master). See the Aesthetics section in the Gadfly docs. For your plot, you could also use wide-form syntax.

Y = [cumsum(randn(20)) for _ in 1:50]
x = repeat([1:20;], outer=50)
plot(Y, x=x, y=Col.value, group=Col.index, color=[colorant"black"], Geom.line)



Thank you for the update. Will this be eventually replacing the use of Theme() or will both options be available?

Theme() can be inside or outside layers (outside is the overall plot Theme).

Inside layers, Theme will still be useful for some geoms e.g. layer(..., Geom.line, Theme(line_width=2pt)), until those attributes are developed into proper aesthetics e.g. layer(..., linewidth=[2pt], Geom.line) .

Sounds good. I like using Theme() to set styles that will be applied to the graph as a whole and then using something like color=[] to style individual geoms.

Thanks for all of your work. I really like the package and I’m always looking forward to future developments.