To specify colors with the layer approach, you can add a theme element to each layer:
colors = [color(c) for c in ["red", "blue", "green", ...]] layers = Layer[] for i=1:10 push!(layers, layer(x=x, y=M[:,i], Geom.line, Theme(default_color=colors[i]))[1]) end The only other way I'm aware of doing this is to convert the matrix to a DataFrame with an extra column to identify each line. So something like: row,col = size(M) data = vcat([DataFrame(x = x, M = M[:,i], line = i*ones(Int, row)) for i in 1:col]) plot(data, x = :x, y = :M, color = :line, Geom.line) On Tuesday, October 21, 2014 9:25:22 PM UTC-7, Dom Luna wrote: > > So I have a vector x and a matrix M. > > The vector x consists of the points on the x axis and the columns of M are > the respective y-cords for each line. > > I'm currently plotting all the lines using layers: > > layers = Layer[] > for i=1:10 > push!(layers, layer(x=x, y=M[:,i], Geom.line)[1]) > end > > plot(layers) > > This gives me essentially what I want except all the lines are same > colour. What's the best way for Gadfly to uniquely colour each line? > > Also if the above layering approach isn't the best way to do what I'm > trying to do please let me know. > > Thanks. >
